Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Amazon-Selection-Data
Overview
Overview
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
abel_cjy
Amazon-Selection-Data
Commits
ca34c459
Commit
ca34c459
authored
May 09, 2025
by
chenyuanjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改mysql连接
parent
42ec1c46
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
db_util.py
Pyspark_job/utils/db_util.py
+4
-4
No files found.
Pyspark_job/utils/db_util.py
View file @
ca34c459
import
os
import
os
import
sys
import
sys
from
enum
import
Enum
from
enum
import
Enum
from
sqlalchemy
import
create_engine
,
text
from
sqlalchemy
import
create_engine
,
text
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
typing
import
Dict
from
typing
import
Dict
from
sqlalchemy.engine
import
Engine
from
sqlalchemy.engine
import
Engine
from
urllib.parse
import
quote_plus
as
urlquote
sys
.
path
.
append
(
os
.
path
.
dirname
(
sys
.
path
[
0
]))
sys
.
path
.
append
(
os
.
path
.
dirname
(
sys
.
path
[
0
]))
...
@@ -34,8 +34,8 @@ class DBUtil(object):
...
@@ -34,8 +34,8 @@ class DBUtil(object):
# mysql连接参数
# mysql连接参数
__mysql_host__
=
"rm-wz9yg9bsb2zf01ea4yo.mysql.rds.aliyuncs.com"
__mysql_host__
=
"rm-wz9yg9bsb2zf01ea4yo.mysql.rds.aliyuncs.com"
__mysql_port__
=
"3306"
__mysql_port__
=
"3306"
__mysql_username__
=
"XP_Yswg2025
_PY
"
__mysql_username__
=
"XP_Yswg2025"
__mysql_pwd__
=
"Xp_Yswg2025
_Py
300"
__mysql_pwd__
=
"Xp_Yswg2025
@
300"
# pg连接参数正式库-h15
# pg连接参数正式库-h15
__pgsql_host__
=
"192.168.10.224"
__pgsql_host__
=
"192.168.10.224"
...
@@ -302,7 +302,7 @@ class DBUtil(object):
...
@@ -302,7 +302,7 @@ class DBUtil(object):
# 获取数据库连接
# 获取数据库连接
elif
conn
[
'db_type'
]
==
'mysql'
:
elif
conn
[
'db_type'
]
==
'mysql'
:
engine
=
create_engine
(
engine
=
create_engine
(
f
"mysql+pymysql://{conn['username']}:{
conn['pwd']
}@{conn['host']}:{conn['port']}/{conn['db_name']}"
,
f
"mysql+pymysql://{conn['username']}:{
urlquote(conn['pwd'])
}@{conn['host']}:{conn['port']}/{conn['db_name']}"
,
pool_size
=
10
,
# 连接池的大小
pool_size
=
10
,
# 连接池的大小
max_overflow
=
20
# 超出连接池大小之外可以创建的连接数
max_overflow
=
20
# 超出连接池大小之外可以创建的连接数
)
)
...
...
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