3 Star 5 Fork 7

Mervin/dbStructExportTool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
db_util_mysql.py 792 Bytes
一键复制 编辑 原始数据 按行查看 历史
Mervin 提交于 2019-11-23 20:46 . project init
import pymysql
def conn_mysql(mysql_host, mysql_port, mysql_user, mysql_password, mysql_dbname, mysql_charset):
return pymysql.connect(host=mysql_host,
port=mysql_port,
user=mysql_user,
password=mysql_password,
db=mysql_dbname,
charset=mysql_charset)
def select_list(conn, sql, data=None):
"""执行操作数据的相关sql"""
cursor = conn.cursor()
cursor.execute(sql, data)
return cursor.fetchall()
def search(conn, sql):
"""执行查询sql"""
cursor = conn.cursor()
cursor.execute(sql)
return cursor.fetchone()
def close_mysql(conn):
"""关闭数据库连接"""
conn.close()
conn.cursor().close()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dymao/dbStructExportTool.git
git@gitee.com:dymao/dbStructExportTool.git
dymao
dbStructExportTool
dbStructExportTool
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385