Category Hierarchy

所以我得到了这个sql (它使用(1,1,1),因为我想排除它为OrderID接受错误参数的可能性(在本例中是1)),它使用如下所示的函数。由于某些原因,它在运行时不会返回错误,但不会更新表,即使它看起来与我代码中其他地方的sql一样,运行得很好。

除了ID之外,我的数据库中的所有字段都设置为文本...我想这就是所有的事情了,提前感谢你的建议。

query("UPDATE Orders SET CustomerID = ?, OrderDate = ? WHERE OrderID = ?", (1, 1, 1))

def query(sql, data = None):
with sqlite3.connect("notDataBase1.db") as db:
    cursor = db.cursor()
    if data == None:
        cursor.execute(sql)
    else:
        cursor.execute(sql, data)
    results = cursor.fetchall()
    return results

转载请注明出处:http://www.cpss-cn.com/article/20230526/2162157.html