Pymssql - 如何避免语法错误“扫描字符串文字时的EOL”

时间:2018-03-06 20:14:12

标签: sql python-3.x

我正在尝试使用SELECT,FROM和WHERE通过模块pymssql进行查询。我在运行脚本时遇到“SyntaxError:EOL,同时扫描字符串文字”。我对SQL语法不太熟悉,但我在SQL上运行它。代码如下:

import pymssql

server = 'ip'
username = 'user'
password = 'pswrd'

cnxn = pymssql.connect(server, username, password, "tempdb")
cursor = cnxn.cursor()

query = "SELECT \"TIME_A\", \"TIME_B\", \"NAME\", \"NAME_B\", SOMETHING, SOMETHINGMORE, \"GROUP ALPHA\" \
        FROM \"DATABASE\".\"db\".\"SUBDATABASE\"  \
        WHERE \"GROUP ALPHA\"=\'PEOPLE A\'        \
        OR \"GROUP ALPHA\"=\'PEOPLE B\'           \
        OR \"GROUP ALPHA\"=\'PEOPLE C\'           \
        OR \"GROUP ALPHA\"=\'PEOPLE D\'           \
        OR \"GROUP ALPHA\"=\'PEOPLE F\'           \
        OR \"GROUP ALPHA\"=\'PEOPLE E\' ";"

我需要帮助来确定我的语法错误在哪里运行得很好,感谢您抽出时间阅读我的询问。

0 个答案:

没有答案