Traceback (most recent call last):
File "D:\python\demo\sublime3\datebase\splite cz.py", line 2, in <module>
import sqlite3
File "D:\python\demo\sublime3\datebase\sqlite3.py", line 4, in <module>
conn = sqlite3.connect('mrsoft.db')
AttributeError: partially initialized module 'sqlite3' has no attribute 'connect' (most likely due to a circular import)
# 导入模块
import sqlite3
# 创建链接对象
conn = sqlite3.connect('mrsoft.db')
# 创建游标对象
cursor = conn.cursor()
# 执行SQL语句
sql = 'insert into suer(id,name) values(1,"mrsoft")'
cursor.execute(sq1)
# 关闭游标
cursor.close()
#提交事务
conn.commit()
# 关闭链接
conn.close()
于2021-07-08 10:52:29编辑