import sqlite3
# 创建连接和游标
def create_conn_and_cur(path='C:\\Users\Administrator\Documents\\Navicat\MySQL\servers\mysite\mysite.sql'):
conn = sqlite3.connect(path)
cur = conn.cursor()
return conn,cur
def execute_query(cur,sql):
cur.execute(sql)
res = cur.fetchall()
return res
def execute_other(conn,cur,sql):
try:
res = cur.execute(sql)
except Exception as e:
print(e)
conn.rollback()
else:
return res
def close_conn_and_cur(conn,cur):
cur.close()
conn.close()
database
最新推荐文章于 2024-08-23 17:37:15 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)