简体   繁体   English

为什么此sqlite3 UPDATE给出语法错误?

[英]Why is this sqlite3 UPDATE giving a syntax error?

I have a function that drops some tables and reinitializes a new set which are working fine, then when it updates the existing table with the following: 我有一个函数可以删除一些表并重新初始化工作良好的新集,然后在使用以下命令更新现有表时:

self.cursor.execute('''UPDATE beers1 SET (beer_name, og, fg, beer_desc, ibu, glass_type, keg_size) 
    VALUES (?,?,?,?,?,?,?) where id=1''',("Beer", 1, 1, "Delicious!", 0, "Pint Glass", 640))

Which then gives me: 这给了我:

OperationalError: near "(": syntax error

Any insight would be incredibly helpful. 任何见解都将非常有用。 Thanks! 谢谢!

The standard SQL syntax for an UPDATE statement is either: UPDATE语句的标准SQL语法为:

UPDATE beers1
   SET (beer_name, og, fg, beer_desc, ibu, glass_type, keg_size) =
       (?, ?, ?, ?, ?, ?, ?)
 WHERE id = 1

Or: 要么:

UPDATE beers1
   SET beer_name = ?, og = ?, fg = ?,
       beer_desc = ?, ibu = ?, glass_type = ?, keg_size = ?
 WHERE id = 1

You will need to check the SQLite3 manual to see which is supported by SQLite3. 您将需要查看SQLite3手册,以了解SQLite3支持哪些手册。 The second is almost guaranteed to be supported; 第二个几乎可以保证得到支持。 the first may not be. 第一个可能不是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM