我有两张桌子,顾客和课程。我想用正确的客户id将日期和时间写入我的课程表的正确行中。我想使用客户登录时输入的用户名从客户表中获取客户id,然后使用该客户id将日期和时间插入正确的位置。这是我的密码:
with sqlite3.connect('sqlite.db') as db:
c = db.cursor()
custid = c.execute('SELECT customerid FROM customers WHERE customerusernm = @username2')
print(custid)
c.execute('INSERT INTO lessons(lessondt,lessontm) VALUES (dt,tm) WHERE custid = customerid')
connect.commit()
connect.close()
我在select语句的行中遇到此错误:
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 0 supplied.
我如何解决这个问题,有没有更好的方法
您必须提供一个元组,该元组的值应绑定在您编写“@username2”的位置。请尝试以下操作:
根据检索用户名的方式,可以使用
getpass
模块:相关问题 更多 >
编程相关推荐