Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling
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
0
Merge Requests
0
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
Commits
3eb41b18
Commit
3eb41b18
authored
Sep 13, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simulation 0913
parent
9155f872
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
25 deletions
+30
-25
dispatch.log
Logs/dispatch.log
+0
-0
settings.py
settings.py
+4
-4
tables.py
tables.py
+26
-21
No files found.
Logs/dispatch.log
View file @
3eb41b18
This diff is collapsed.
Click to expand it.
settings.py
View file @
3eb41b18
...
@@ -28,8 +28,8 @@ import time
...
@@ -28,8 +28,8 @@ import time
log_path
=
"/usr/local/fleet-log/dispatch"
log_path
=
"/usr/local/fleet-log/dispatch"
# 创建日志目录
# 创建日志目录
#
if not os.path.exists(log_path):
if
not
os
.
path
.
exists
(
log_path
):
#
os.mkdir(log_path)
os
.
mkdir
(
log_path
)
# logging初始化工作
# logging初始化工作
logging
.
basicConfig
()
logging
.
basicConfig
()
...
@@ -39,8 +39,8 @@ logger.setLevel(logging.INFO)
...
@@ -39,8 +39,8 @@ logger.setLevel(logging.INFO)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
#
filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", maxBytes=3*1024*1024, backupCount=10)
filehandler
=
logging
.
handlers
.
RotatingFileHandler
(
log_path
+
"/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
filehandler
=
logging
.
handlers
.
RotatingFileHandler
(
"./Logs/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
#
filehandler = logging.handlers.RotatingFileHandler("./Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10)
# 设置后缀名称,跟strftime的格式一样
# 设置后缀名称,跟strftime的格式一样
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
...
...
tables.py
View file @
3eb41b18
...
@@ -14,37 +14,42 @@ from sqlalchemy import Column, create_engine
...
@@ -14,37 +14,42 @@ from sqlalchemy import Column, create_engine
from
sqlalchemy
import
VARCHAR
,
DateTime
,
Float
,
Integer
,
BOOLEAN
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
# import numpy as np
from
urllib.parse
import
quote
# from redis import StrictRedis, ConnectionPool
from
settings
import
*
# import redis
# from datetime import datetime, timedelta
# import copy
# import json
# import sched
# import time
# 创建对象的基类:
Base
=
declarative_base
()
Base
=
declarative_base
()
# 初始化数据库连接:
try
:
engine_mysql
=
create_engine
(
'mysql+mysqlconnector://root:Huituo@123@192.168.28.111:3306/waytous'
)
engine_mysql
=
create_engine
(
"mysql+mysqlconnector://root:
%
s@192.168.28.111:3306/waytous"
%
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
(
'postgresql://postgres:Huituo@123@192.168.28.111:5432/shenbao_2021520'
)
DBsession_mysql
=
scoped_session
(
DBsession_mysql
)
# 创建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_postgre
=
DBsession_postgre
()
session_postgre
.
expire_on_commit
=
False
except
Exception
as
es
:
logger
.
error
(
"数据库连接失败"
)
logger
.
error
(
es
)
# 定义对象:
# 定义对象:
...
...
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