From aa110dd149c677ef9b41895db56936d121c1dfbc Mon Sep 17 00:00:00 2001 From: Stewart Douglas Date: Thu, 13 Aug 2015 10:14:38 -0400 Subject: [PATCH] ENH: Add init_db to transaction so table exists=>it has also been written to --- zipline/assets/asset_writer.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zipline/assets/asset_writer.py b/zipline/assets/asset_writer.py index 25323040..b942ff49 100644 --- a/zipline/assets/asset_writer.py +++ b/zipline/assets/asset_writer.py @@ -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)