替换L,在SQL中生成python

2024-04-25 19:08:26 发布

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

我运行pyodbc连接到我的数据库,当我运行一个简单的查询时,我会得到一堆结果,比如

(7L, )(12L,) etc. 

如何用“”替换“L”,以便将ID传递到另一个查询中

谢谢

这是我的密码

import pyodbc
cnxn = pyodbc.connect('DSN=...;UID=...;PWD=...', ansi=True)
cursor = cnxn.cursor()
rows = cursor.execute("select id from orders")
for row in rows:
    test = cursor.execute("select name from customer where order_id = %(id)s" %{'id':row})
    print test

Tags: fromtestid数据库密码executeetcselect