Commit dca1c2f1 authored by Allvey's avatar Allvey

simulation 091301

parent 3eb41b18
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
from tables import * from tables import *
from urllib.parse import quote from urllib.parse import quote
import logging.handlers import logging.handlers
from redis import StrictRedis, ConnectionPool
import numpy as np import numpy as np
import os import os
from redis import StrictRedis, ConnectionPool from redis import StrictRedis, ConnectionPool
......
...@@ -15,41 +15,61 @@ from sqlalchemy import VARCHAR, DateTime, Float, Integer, BOOLEAN ...@@ -15,41 +15,61 @@ from sqlalchemy import VARCHAR, DateTime, Float, Integer, BOOLEAN
from sqlalchemy.orm import sessionmaker, scoped_session from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from urllib.parse import quote from urllib.parse import quote
from settings import *
# 创建对象的基类:
Base = declarative_base() Base = declarative_base()
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") )
)
engine_postgre = create_engine(
"postgresql://postgres:%s@192.168.28.111:5432/shenbao_2021520"
% quote("Huituo@123")
)
# 创建DBsession_mysql类型:
DBsession_mysql = sessionmaker(bind=engine_mysql)
engine_postgre = create_engine( DBsession_mysql = scoped_session(DBsession_mysql)
"postgresql://postgres:%s@192.168.28.111:5432/shenbao_2021520"
% quote("Huituo@123")
)
# 创建DBsession_mysql类型: DBsession_postgre = sessionmaker(bind=engine_postgre)
DBsession_mysql = sessionmaker(bind=engine_mysql)
DBsession_mysql = scoped_session(DBsession_mysql) DBsession_postgre = scoped_session(DBsession_postgre)
DBsession_postgre = sessionmaker(bind=engine_postgre) # 创建session_mysql对象:
session_mysql = DBsession_mysql()
DBsession_postgre = scoped_session(DBsession_postgre) session_mysql.expire_on_commit = False
# 创建session_mysql对象: session_postgre = DBsession_postgre()
session_mysql = DBsession_mysql()
session_mysql.expire_on_commit = False session_postgre.expire_on_commit = False
session_postgre = DBsession_postgre()
session_postgre.expire_on_commit = False # # 创建对象的基类:
except Exception as es: # Base = declarative_base()
logger.error("数据库连接失败") #
logger.error(es) # # 初始化数据库连接:
# engine_mysql = create_engine('mysql+mysqlconnector://root:Huituo@123@192.168.28.111:3306/waytous')
#
# engine_postgre = create_engine('postgresql://postgres:Huituo@123@192.168.28.111:5432/shenbao_2021520')
#
# # 创建DBsession_mysql类型:
# DBsession_mysql = sessionmaker(bind=engine_mysql)
#
# DBsession_mysql = scoped_session(DBsession_mysql)
#
# DBsession_postgre = sessionmaker(bind=engine_postgre)
#
# DBsession_postgre = scoped_session(DBsession_postgre)
#
# # 创建session_mysql对象:
# session_mysql = DBsession_mysql()
#
# session_postgre = DBsession_postgre()
# 定义对象: # 定义对象:
......
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