Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.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
Python 使用execute()执行多个SQL语句_Python_Sql_Mariadb_Sql Injection_Stacked Query - Fatal编程技术网

Python 使用execute()执行多个SQL语句

Python 使用execute()执行多个SQL语句,python,sql,mariadb,sql-injection,stacked-query,Python,Sql,Mariadb,Sql Injection,Stacked Query,我正试图在我的服务器上进行SQL注入。 我正在使用命令: cursor.execute("select * from some_table") 在我的服务器中执行SQL命令。 但是有没有一种方法可以使用相同的execute()函数执行多个命令。 我试过: cursor.execute("select * from some_table ; INSERT INTO ...") DBMS是对SQL注入策略的概述。您尝试执行的一个操作称为堆叠查询。似乎至少大

我正试图在我的服务器上进行
SQL注入。
我正在使用命令:

cursor.execute("select * from some_table")
在我的服务器中执行SQL命令。 但是有没有一种方法可以使用相同的
execute()
函数执行多个命令。
我试过:

cursor.execute("select * from some_table ; INSERT INTO ...")
DBMS是对SQL注入策略的概述。您尝试执行的一个操作称为堆叠查询。似乎至少大多数数据库API都阻止了这种策略

您提到的MariaDB基本上与MySQL相同

尽管python没有明确列出,但我还假设python数据库API阻止了查询堆叠


更新:当您检查
execute()
的API时,您可以看到一个参数
multi
,默认为
False
。只要不将其设置为
True
,就应该是安全的。

不,它一次只允许执行一条语句。只需多次调用
cursor.execute()
。您可以查看
executemany
,例如,它可以在一次通话中插入多行数据,比多次通话更有效。谢谢您的回答。