PERF: Reflect the db schema once instead of per table

This commit is contained in:
Richard Frank
2015-10-01 08:55:02 -04:00
parent beac4d6f16
commit 8b98ca7d71
+6 -30
View File
@@ -82,36 +82,12 @@ class AssetFinder(object):
self.engine = engine
metadata = sa.MetaData(bind=engine)
self.equities = sa.Table(
'equities',
metadata,
autoload=True,
autoload_with=engine,
)
self.futures_exchanges = sa.Table(
'futures_exchanges',
metadata,
autoload=True,
autoload_with=engine,
)
self.futures_root_symbols = sa.Table(
'futures_root_symbols',
metadata,
autoload=True,
autoload_with=engine,
)
self.futures_contracts = sa.Table(
'futures_contracts',
metadata,
autoload=True,
autoload_with=engine,
)
self.asset_router = sa.Table(
'asset_router',
metadata,
autoload=True,
autoload_with=engine,
)
table_names = ['equities', 'futures_exchanges', 'futures_root_symbols',
'futures_contracts', 'asset_router']
metadata.reflect(only=table_names)
for table_name in table_names:
setattr(self, table_name, metadata.tables[table_name])
# Cache for lookup of assets by sid, the objects in the asset lookp may
# be shared with the results from equity and future lookup caches.