复制行时出现python sqlite3语法错误

复制行时出现python sqlite3语法错误,python,sqlite,Python,Sqlite,在python中使用sqlite3(2.6.1不问)将一行从一个表复制到另一个表时遇到问题。我可以指定一列,但如果我添加第二列,它会给我一个错误 import sqlite3 conn = sqlite3.connect("database.db") cursor = conn.cursor() #this works: cursor.execute("insert into table2 (name) select (name) from table1") cursor.execute("i

在python中使用sqlite3(2.6.1不问)将一行从一个表复制到另一个表时遇到问题。我可以指定一列,但如果我添加第二列,它会给我一个错误

import sqlite3

conn = sqlite3.connect("database.db")
cursor = conn.cursor()
#this works: cursor.execute("insert into table2 (name) select (name) from table1")
cursor.execute("insert into table2 (name, title) select (name, title) from table1") #this doesn't
conn.commit()
cursor.close()
结果:

sqlite3.OperationalError: near ",": syntax error

有什么好处?我知道SQLite语法是正确的,但sqlite3不会接受它。请原谅,如果以前有人问过这个问题,逗号往往会从结果中过滤掉,因此很难搜索。

您不应该在
选择后加括号。应该是:

insert into table2 (name, title) select name, title from table1