Python sqlite3查询中无法使用条件(>,<,=)

2024-09-30 23:45:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我遇到了一个奇怪的问题

设置为:Python3.6.5和sqlite3

我正在数据库中运行一个简单查询,假设“c”是我的游标对象:

c.execute("select count from mydb where bytes is ?",(myvariable,))

这绝对可以,但如果我要添加“>;”对它

c.execute("select count from mydb where bytes is > ?",(myvariable,))

我得到以下错误:

OperationalError: near ">": syntax error

这在python 2.7中运行得非常好

如果你能帮我,我将不胜感激

问候,

哈利


Tags: 对象fromgt数据库executebytesiscount