Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If-Then列的条件,SQLite3-Python_Python_Sqlite - Fatal编程技术网

If-Then列的条件,SQLite3-Python

If-Then列的条件,SQLite3-Python,python,sqlite,Python,Sqlite,我在数据库data.sqlite中有一个表data: 'my_path/data.sqlite' A B 0 0 1 1 0 1 1 0 我想在此表中添加一个新列,如果a=B,则每个值均为1,否则为0 我可以通过以下操作创建一个新列: conn = sqlite3.connect('my_path/data.sqlite') cur = conn.cursor() cur.execute("ALTER TABLE data ADD COLUMN Agreement") conn.commit

我在数据库
data.sqlite
中有一个表
data

'my_path/data.sqlite'

A B
0 0
1 1
0 1
1 0
我想在此表中添加一个新列,如果a=B,则每个值均为1,否则为0

我可以通过以下操作创建一个新列:

conn = sqlite3.connect('my_path/data.sqlite')
cur = conn.cursor()
cur.execute("ALTER TABLE data ADD COLUMN Agreement")
conn.commit()

A B Agreement
0 0
1 1
0 1
1 0
然后我尝试一个条件语句:其中a和B相等,使用
更新集CASE
函数a la:

但我一直得到:

OperationalError: near "Agreement": syntax error

我做错了什么?

嗯。。。该字符串的开头将是
更新数据集协议
。。。在解释器中键入
“更新数据”“设置协议”
,查看…@JonClements Facepalm。。。谢谢你。。。该字符串的开头将是
更新数据集协议
。。。在解释器中键入
“更新数据”“设置协议”
,查看…@JonClements Facepalm。。。谢谢
OperationalError: near "Agreement": syntax error