我有两个表,客户和课程。我想使用正确的客户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.
我该如何解决这个问题,还有更好的方法吗?