You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
481 B

from pymysql import *
conn = connect(host='localhost', user='root', password='123456', database='tianqi', port=3306)# 设置数据库连接信息
cursor = conn.cursor()
def query(sql, params, type='no_select'):
params = tuple(params)
cursor.execute(sql, params)
if type != 'no_select':
data_list = cursor.fetchall()
conn.commit()
return data_list
else:
conn.commit()
return '数据库语句执行成功'