转移
This commit is contained in:
16
models/mysql.py
Normal file
16
models/mysql.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import pymysql
|
||||
from configs.config import MYSQL_HOST
|
||||
|
||||
|
||||
# 连接 MySQL (开启 MySQL 服务)
|
||||
conn = pymysql.connect(host=MYSQL_HOST, user="gameui", port=3306, password="gameui@2022", database='gameui', local_infile=True, cursorclass=pymysql.cursors.DictCursor)
|
||||
|
||||
|
||||
# 获取 MySQL 连接
|
||||
def get_cursor():
|
||||
try:
|
||||
dx = conn.ping()
|
||||
return conn.cursor()
|
||||
except Exception:
|
||||
conn = pymysql.connect(host=MYSQL_HOST, user="gameui", port=3306, password="gameui@2022", database='gameui', local_infile=True, cursorclass=pymysql.cursors.DictCursor)
|
||||
return conn.cursor()
|
Reference in New Issue
Block a user