mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-29 05:55:11 +08:00
PERF: Reflect the db schema once instead of per table
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user