小编Ale*_*lex的帖子

在 pymssql 中使用带有 IN sql 语句的 cursor.execute 参数

我在通过 pymssql 使用带有操作符 IN 的简单 sql 语句时遇到了麻烦。

这是一个示例:

import pymssql
conn = pymssql.connect(server='myserver', database='mydb')
cursor = conn.cursor()
req = "SELECT * FROM t1 where id in (%s)"
cursor.execute(req,  tuple(range(1,10)))
res = cursor.fetchall()
Run Code Online (Sandbox Code Playgroud)

令人惊讶的是,只返回了第一个 id,我不知道为什么。有没有人遇到同样的行为?

python sql pymssql

7
推荐指数
1
解决办法
3088
查看次数

标签 统计

pymssql ×1

python ×1

sql ×1