ENH: Add init_db to transaction so table exists=>it has also been written to

This commit is contained in:
Stewart Douglas
2015-08-13 10:14:38 -04:00
committed by jfkirk
parent 667f0695d5
commit aa110dd149
+6 -4
View File
@@ -110,11 +110,13 @@ class AssetDBWriter(with_metaclass(ABCMeta)):
"""
self.allow_sid_assignment = allow_sid_assignment
# Create SQL tables
self.init_db(engine, constraints)
# Get the data to add to SQL
data = self.load_data()
with engine.begin() as txn:
# Create SQL tables.
self.init_db(txn, constraints)
# Get the data to add to SQL.
data = self.load_data()
# Write the data to SQL.
self._write_exchanges(data.exchanges, txn)
self._write_root_symbols(data.root_symbols, txn)
self._write_futures(data.futures, txn)