【问题标题】:Invalid column name 'Escalation'列名“升级”无效
【发布时间】:2021-11-03 17:42:37
【问题描述】:

我正在使用 PyODBC 从 MS SQL 数据库中获取数据。

这是我的代码:

query = ''' 
    select a.created, a.asset_num, a.description, a.resolution, a.type, a.subtype
    from SC_SR_EXPORT_V as a
    where TYPE = "Escalation";
'''
data = pd.read_sql(query, cnxn)
data.head()

我收到以下错误:

DatabaseError: sql 执行失败' 选择 a.created、a.asset_num、a.description、a.resolution、a.type、a.subtype 从 SC_SR_EXPORT_V 作为 其中 TYPE = "升级"; ': ('42S22', "[42S22] [Microsoft][ODBC SQL Server Driver][SQL Server]列名'Escalation'无效。(207) (SQLExecDirectW)")

【问题讨论】:

    标签: sql sql-server pyodbc


    【解决方案1】:

    我已将 where TYPE = "Escalation" 更改为 where TYPE = 'Escalation' 并且有效。 显然,出于某种原因,它不喜欢双引号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-28
      • 1970-01-01
      • 2019-12-29
      • 2016-07-16
      • 2018-10-14
      • 2019-05-18
      • 2013-09-30
      • 1970-01-01
      相关资源
      最近更新 更多