How to see the real SQL query in Python cursor.execute using pyodbc and MS-Access

前端 未结 9 1425
有刺的猬
有刺的猬 2020-12-04 17:17

I use the following code in Python (with pyodbc for a MS-Access base).

cursor.execute(\"select a from tbl where b=? and c=?\", (x, y))

It\'

9条回答
  •  误落风尘
    2020-12-04 18:13

    Write the sql string and then execute it:

    sql='''select a 
           from tbl 
           where b=? 
           and c=? '''
    
    cursor.execute(sql, x, y)
    print 'just executed:',(sql, x,y)
    

    Now you can do whatever you want with the SQL statement.

提交回复
热议问题