Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl_ai_recommender
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
闫发泽
ydl_ai_recommender
Commits
9acf0300
Commit
9acf0300
authored
Nov 28, 2022
by
柴鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增数据库连接类
parent
4bd5fb43
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
0 deletions
+53
-0
default.conf
conf/default.conf
+7
-0
environment.yaml
environment.yaml
+11
-0
requirements.txt
requirements.txt
+1
-0
mysql_client.py
src/data/mysql_client.py
+34
-0
No files found.
conf/default.conf
0 → 100644
View file @
9acf0300
[
ADB
]
host
=
am
-
bp1w063w3g4908x1890650o
.
ads
.
aliyuncs
.
com
port
=
3306
user
=
password
=
environment.yaml
0 → 100644
View file @
9acf0300
# run: conda env create --file environment.yaml
name
:
yar
channels
:
-
defaults
dependencies
:
-
python==3.8
-
ipykernel
-
pip
-
pip
:
-
-r requirements.txt
\ No newline at end of file
requirements.txt
0 → 100644
View file @
9acf0300
pymysql
src/data/mysql_client.py
0 → 100644
View file @
9acf0300
# -*- coding: utf-8 -*-
import
pymysql
class
MySQLClient
():
def
__init__
(
self
,
host
,
port
,
user
,
password
,
logger
=
None
)
->
None
:
self
.
logger
=
logger
self
.
connection
=
pymysql
.
connect
(
host
=
host
,
port
=
port
,
user
=
user
,
password
=
password
,
charset
=
'utf8mb4'
,
cursorclass
=
pymysql
.
cursors
.
DictCursor
)
self
.
cursor
=
self
.
connection
.
cursor
()
if
self
.
logger
:
self
.
logger
.
info
(
'数据库连接成功'
)
def
query
(
self
,
sql
):
row_count
=
self
.
cursor
.
execute
(
sql
)
data
=
self
.
cursor
.
fetchall
()
return
row_count
,
data
def
__del__
(
self
):
try
:
self
.
cursor
.
close
()
self
.
connection
.
close
()
print
(
'dataset disconnected'
)
except
Exception
as
e
:
print
(
e
)
\ No newline at end of file
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