python - Sqlite3 在查找数据时给出错误 2 个参数 (7given)
问题描述
def addPersonRec(Firstname, Surname, DoB, Age, Notes, DateCreated):
con=sqlite3.connect("silver.db")
cur = con.cursor()
cur.execute("INSERT INTO silver VAULES (NULL, ?, ?, ?, ?, ?, ?)", Firstname, Surname, DoB, Age, Notes, DateCreated)
con.commit()
con.close()
所以我的问题是我已经引入了 sqlite 3,当我运行它时,我在 addPersonRec cur.execute("INSERT INTO silver VAULES (NULL, ?, ?, ?, ?, ?, ?)",Firstname , Surname, DoB, Age, Notes, DateCreated)
TypeError: function take at most 2 arguments (7 given) 请任何想法帮助
解决方案
.execute
的第二个参数应该是一个元组。
另请注意,您有一个错字。VAULES
应该是VALUES
。
cur.execute("INSERT INTO silver VALUES (NULL, ?, ?, ?, ?, ?, ?)",
(Firstname, Surname, DoB, Age, Notes, DateCreated))
推荐阅读
- kotlin - 在 Kotlin 中选择并显示日期
- ios - 快速视频流启动
- c# - 导出到统一时,搅拌机模型不导出材料。请帮忙?
- maven - Maven surefire插件输出测试摘要xml?
- android - 辅助功能节点信息获取图像内容
- laravel - Laravel:使用 Trait 和 Scope 检查该字段是否在路由中填写
- go - Golang 多部分文件表单请求
- android - RxJava observeOn currentThread 调用 opengl 函数
- .net - TLS 1.2 和现有连接被远程主机强行关闭
- r - R 绘图,名称在 y 轴上,值在 x 轴上