Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling-v3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张晓彤
integrated-scheduling-v3
Commits
3faa8a40
Commit
3faa8a40
authored
Jul 19, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理路网异常捕获
parent
05b303a3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
tables.py
tables.py
+19
-20
No files found.
tables.py
View file @
3faa8a40
...
@@ -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,8 +68,8 @@ sql_str = str("mysql+mysqlconnector://" + mysql_config["user"] + ":%s@" + mysql_
...
@@ -69,8 +68,8 @@ 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")
...
@@ -78,9 +77,9 @@ try:
...
@@ -78,9 +77,9 @@ try:
# "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")
...
@@ -88,29 +87,29 @@ try:
...
@@ -88,29 +87,29 @@ try:
# "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
# 定义对象:
# 定义对象:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment