Commit 26510178 authored by Dr.李's avatar Dr.李

update sql engine

parent 324a4396
...@@ -81,6 +81,8 @@ total_risk_factors = risk_styles + industry_styles + macro_styles ...@@ -81,6 +81,8 @@ total_risk_factors = risk_styles + industry_styles + macro_styles
factor_tables = [FullFactorView, Experimental] factor_tables = [FullFactorView, Experimental]
DEFAULT_URL = 'postgresql+psycopg2://postgres:A12345678!@10.63.6.220/alpha'
def _map_risk_model_table(risk_model: str) -> tuple: def _map_risk_model_table(risk_model: str) -> tuple:
if risk_model == 'day': if risk_model == 'day':
...@@ -113,8 +115,12 @@ def _map_industry_category(category: str) -> str: ...@@ -113,8 +115,12 @@ def _map_industry_category(category: str) -> str:
class SqlEngine(object): class SqlEngine(object):
def __init__(self, def __init__(self,
db_url: str): db_url: str=None):
self.engine = sa.create_engine(db_url) if db_url:
self.engine = sa.create_engine(db_url)
else:
self.engine = sa.create_engine(DEFAULT_URL)
self.session = None self.session = None
self.create_session() self.create_session()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment