diff --git a/zipline/assets/asset_db_migrations.py b/zipline/assets/asset_db_migrations.py index 82f9d147..2b1431c5 100644 --- a/zipline/assets/asset_db_migrations.py +++ b/zipline/assets/asset_db_migrations.py @@ -24,7 +24,7 @@ def downgrade(engine, desired_version): """ # Check the version of the db at the engine - with engine.connect() as conn: + with engine.begin() as conn: metadata = sa.MetaData(conn) metadata.reflect() version_info_table = metadata.tables['version_info'] @@ -100,7 +100,7 @@ def downgrades(src): @do(op.setitem(_downgrade_methods, destination)) @wraps(f) def wrapper(op, conn, version_info_table): - version_info_table.delete().execute() # clear the version + conn.execute(version_info_table.delete()) # clear the version f(op) write_version_info(conn, version_info_table, destination) diff --git a/zipline/assets/asset_writer.py b/zipline/assets/asset_writer.py index 50e9070d..050904ee 100644 --- a/zipline/assets/asset_writer.py +++ b/zipline/assets/asset_writer.py @@ -442,9 +442,9 @@ class AssetDBWriter(object): -------- zipline.assets.asset_finder """ - with self.engine.begin() as txn: + with self.engine.begin() as conn: # Create SQL tables if they do not exist. - self.init_db(txn) + self.init_db(conn) # Get the data to add to SQL. data = self._load_data( @@ -457,25 +457,25 @@ class AssetDBWriter(object): self._write_df_to_table( futures_exchanges, data.exchanges, - txn, + conn, chunk_size, ) self._write_df_to_table( futures_root_symbols, data.root_symbols, - txn, + conn, chunk_size, ) self._write_assets( 'future', data.futures, - txn, + conn, chunk_size, ) self._write_assets( 'equity', data.equities, - txn, + conn, chunk_size, mapping_data=data.equities_mappings, )