mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-16 11:18:11 +08:00
MAINT: Put downgrade in transaction
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user