Error:rows = c.fetchall()cx_Oracle.InterfaceError:不是查询

问题描述 投票:0回答:1
import cx_Oracle
import pandas as pd

dsn_tns = cx_Oracle.makedsn('hostname', 'port', sid='id')
conn = cx_Oracle.connect(user=r'username', password='password', dsn=dsn_tns) 

c = conn.cursor()
c.execute 
('SELECT * FROM(SELECT SGUID,(pd.to_datetime(DTIMESTAMP)Decoded_Date  FROM table_name)SUB WHERE SUB.Decoded_Date between 1,SEP,2019 and 29,OCT,2019;')

rows = c.fetchall()
for row in rows:
    print(row)
python oracle interface trace cx-oracle
1个回答
0
投票
嗯,您编写的查询完全无效,根本没有意义。您应该首先使其工作,然后将其合并到Python中。

我什至不知道建议如何使其工作为>>

    我没有您的表格或数据,
  • 我不知道pd.to_datetime是什么(看起来像pd所拥有的功能,或者是pd包的一部分)
    • 它接受一个参数-它是什么数据类型?它返回什么?看起来像“解码日期”,但是-哪种格式?我建议您使用日期(或时间戳记),而不是字符串!
  • 1,sep,2019之间看起来像一个日期,但至少应将其括在单引号中以表示字符串,但是-如果使用这种格式,则将得到无效的结果集(如果有的话!)。
  • 也许,只是

    也许这样的东西可能有用。如果没有,那就是应该的样子:select sguid, dtimestamp from table_name where dtimestamp between date '2019-09-01' and date '2019-10-29'

  • © www.soinside.com 2019 - 2024. All rights reserved.