具有下列特征:
array = ['', 'kujawski=', "'", "select * from symbols where name = '='", ';drop table;', 'fakeone=']
我可以轻松生成以下查询:
//(query, array)
('select count(*) from symbols where name in (?,?,?,?,?,?)', ('', 'kujawski=', "'", "select * from symbols where name = '='", ';drop table;', 'fakeone='))
要生成可以放入cursor.execute()函数中的查询,我目前正在通过以下代码执行:
"select count(*) from table where name in (%s)" % ",".join("?"*len(array)),array
函数返回所需的输出。然而,问题是何时我想使用AND筛选查询,例如:
select count(*) from table where name in (...) and column5 in (...)
我不知道如何在python中生成查询,哪个cursor.execute()函数将接受它,请帮助-谢谢
我不确定您的第二个带有连接的
select
语句想要实现什么。第一行是您应该传递给cur.execute()
的内容。例如:这也将防止SQL注入攻击,这正是您自己试图利用的
如果要执行
drop
语句等,那么应该使用cur.execute()
自行处理,而不是像您正在尝试的那样,将其作为另一个命令中的嵌入命令事实上,我完全不知道你想用这个来完成什么。这是您在sqlite完成后的声明(大致)
相关问题 更多 >
编程相关推荐