PYODBC sql 语句中的 with 语句

Oxford_orange

如果我在 SQL 语句中使用 With 子句,我将无法使用 pyodbc 执行 SQL 语句。

这有效:

import pyodbc

cnxn = pyodbc.connect('DSN=database;PWD=password' )
cursor = cnxn.cursor()

sql = """
    SELECT top 10 *                                 
    FROM    table
    """
qnnum = pd.read_sql(sql, cnxn)

这不起作用:

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)
尤根德M

我已经在 Teradata(15.10.07.37)上使用 pyodbc(Python 3.7)测试了 WITH 子句并且它有效。

在以下形式的查询字符串中也支持注释。

/* 评论 1 */

希望有帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章