Commit 3faa8a40 authored by 张晓彤's avatar 张晓彤

处理路网异常捕获

parent 05b303a3
...@@ -59,7 +59,6 @@ with open(json_file) as f: ...@@ -59,7 +59,6 @@ with open(json_file) as f:
# #
# session_postgre.expire_on_commit = False # session_postgre.expire_on_commit = False
# 创建对象的基类: # 创建对象的基类:
Base = declarative_base() Base = declarative_base()
...@@ -69,48 +68,48 @@ sql_str = str("mysql+mysqlconnector://" + mysql_config["user"] + ":%s@" + mysql_ ...@@ -69,48 +68,48 @@ sql_str = str("mysql+mysqlconnector://" + mysql_config["user"] + ":%s@" + mysql_
postgre_str = str("postgresql://" + postgre_config["user"] + ":%s@" + postgre_config["host"] + \ postgre_str = str("postgresql://" + postgre_config["user"] + ":%s@" + postgre_config["host"] + \
":" + postgre_config["port"] + "/" + postgre_config["database"]) ":" + postgre_config["port"] + "/" + postgre_config["database"])
try: # try:
engine_mysql = create_engine( engine_mysql = create_engine(
# "mysql+mysqlconnector://root:%s@192.168.28.111:3306/waytous" # "mysql+mysqlconnector://root:%s@192.168.28.111:3306/waytous"
# % quote("Huituo@123") # % quote("Huituo@123")
# "mysql+mysqlconnector://" + mysql_config["user"] + ":" + mysql_config["password"] + "@" + mysql_config[ # "mysql+mysqlconnector://" + mysql_config["user"] + ":" + mysql_config["password"] + "@" + mysql_config[
# "host"] + ":" + mysql_config["port"] + "/" + mysql_config["database"] # "host"] + ":" + mysql_config["port"] + "/" + mysql_config["database"]
sql_str % quote(mysql_config["password"]) sql_str % quote(mysql_config["password"])
) )
engine_postgre = create_engine( engine_postgre = create_engine(
# "postgresql://postgres:%s@192.168.28.111:5432/shenbao_2021520" # "postgresql://postgres:%s@192.168.28.111:5432/shenbao_2021520"
# % quote("Huituo@123") # % quote("Huituo@123")
# "postgresql://" + postgre_config["user"] + ":" + postgre_config["password"] + "@" + postgre_config[ # "postgresql://" + postgre_config["user"] + ":" + postgre_config["password"] + "@" + postgre_config[
# "host"] + ":" + postgre_config["port"] + "/" + postgre_config["database"] # "host"] + ":" + postgre_config["port"] + "/" + postgre_config["database"]
postgre_str % quote(postgre_config["password"]) postgre_str % quote(postgre_config["password"])
) )
# 创建DBsession_mysql类型: # 创建DBsession_mysql类型:
DBsession_mysql = sessionmaker(bind=engine_mysql) DBsession_mysql = sessionmaker(bind=engine_mysql)
DBsession_mysql = scoped_session(DBsession_mysql) DBsession_mysql = scoped_session(DBsession_mysql)
DBsession_postgre = sessionmaker(bind=engine_postgre) DBsession_postgre = sessionmaker(bind=engine_postgre)
DBsession_postgre = scoped_session(DBsession_postgre) DBsession_postgre = scoped_session(DBsession_postgre)
# 创建session_mysql对象: # 创建session_mysql对象:
session_mysql = DBsession_mysql() session_mysql = DBsession_mysql()
session_mysql.expire_on_commit = False session_mysql.expire_on_commit = False
session_postgre = DBsession_postgre() session_postgre = DBsession_postgre()
session_postgre.expire_on_commit = False session_postgre.expire_on_commit = False
except Exception as es: # except Exception as es:
# logger.error("数据库连接失败") # # logger.error("数据库连接失败")
# logger.error(es) # # logger.error(es)
pass # pass
# 定义对象: # 定义对象:
......
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