为了账号安全,请及时绑定邮箱和手机立即绑定

使用 Python 从 SAP Hana 加载数据时出现语法错误

使用 Python 从 SAP Hana 加载数据时出现语法错误

天涯尽头无女友 2023-03-08 10:39:05
我在通过 Python 从 SAP HANA 加载数据时遇到问题。代码在以下情况下工作正常:connection = pyhdb.connect(|||credentials|||)cursor = connection.cursor()cursor.execute('SELECT "0COMP_CODE", "0VENDOR", "0REF_DOC_NO", "0BBP_INV_ID" FROM  "_SYS_BIC"."system-local.bw.bw2hana/ZFGL01MY" WHERE CAST( "0PSTNG_DATE" AS date) >= ADD_MONTHS( NEXT_DAY( LAST_DAY( CURRENT_DATE)), -2) and "0VENDOR" IS NOT NULL')但是当我试图添加像“0COMP_CODE”='B2B'这样的条件时,所以它看起来像这样:Connection = pyhdb.connect(|||credentials|||)cursor = connection.cursor()cursor.execute('SELECT "0COMP_CODE", "0VENDOR", "0REF_DOC_NO", "0BBP_INV_ID" FROM  "_SYS_BIC"."system-local.bw.bw2hana/ZFGL01MY" WHERE CAST( "0PSTNG_DATE" AS date) >= ADD_MONTHS( NEXT_DAY( LAST_DAY( CURRENT_DATE)), -2) and "0VENDOR" IS NOT NULL AND "0COMP_CODE" = 'B2B' ')我越来越SyntaxError: invalid syntax.我做错了什么?
查看完整描述

1 回答

?
青春有我

TA贡献1784条经验 获得超8个赞

尝试转义单引号:


Connection = pyhdb.connect(|||credentials|||)

cursor = connection.cursor()

cursor.execute('SELECT "0COMP_CODE", "0VENDOR", "0REF_DOC_NO", "0BBP_INV_ID" FROM  "_SYS_BIC"."system-local.bw.bw2hana/ZFGL01MY" WHERE CAST( "0PSTNG_DATE" AS date) >= ADD_MONTHS( NEXT_DAY( LAST_DAY( CURRENT_DATE)), -2) and "0VENDOR" IS NOT NULL AND "0COMP_CODE" = \'B2B\' ')


查看完整回答
反对 回复 2023-03-08
  • 1 回答
  • 0 关注
  • 76 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信