如果db2查询返回0条记录,请检查什么

时间:2018-01-13 09:50:20

标签: python db2

我正在从python 3.x执行db2查询。在执行查询之前,我正在为查询&提取python字符串。在松鼠身上检查它。查询正在执行&返回结果。这是我的查询

select distinct Cno  from df_J_CUST where ID in ('95427','95405','95429') and  GRP not in ('K915B','K9F0S','K9M4U','K9QBJ','K0012AS','K0015R5','K001877','K001H1N','K95U5','K9GEX','K9M6L','K9YGP','K00159S','K00184E','K226QMF') and  CODE in ('1PY2','5AR1','9U1Y') and TYPE = 'L'

但是在使用此代码从python执行它时

    import pandasql as pdsql
    str1 = """select distinct Cno  from df_J_CUST where %s"""
    str="ID in ('95427','95405','95429') and GRP not in ('K915B','K9F0S','K9M4U','K9QBJ','K0012AS','K0015R5','K00187‌​7','K001H1N','K95U5'‌​,'K9GEX','K9M6L','K9‌​YGP','K00159S','K001‌​84E','K226QMF') and CODE in ('1PY2','5AR1','9U1Y') and TYPE = 'L'"
    str2 = str1%(str)
    print("str2=", str2)
    pysql = lambda q: pdsql.sqldf(q, globals())
    df1 = pysql(str2)

我没有看到任何错误消息,但查询返回0条记录。你能告诉我我需要检查什么来找出问题吗?

0 个答案:

没有答案