I am not able to execute a SQL statement with pyodbc if I use the With clause in the SQL statement.
This works:
import pyodbc
cnxn = pyodbc.connect('DSN=database;PWD=password' )
cursor = cnxn.cursor()
sql = """
SELECT top 10 *
FROM table
"""
qnnum = pd.read_sql(sql, cnxn)
This does NOT work:
import pyodbc
cnxn = pyodbc.connect('DSN=database;PWD=password' )
cursor = cnxn.cursor()
sql = """
With A as(SELECT top 10 *
FROM table)
select * from A
"""
qnnum = pd.read_sql(sql, cnxn)