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)
我什至不知道建议如何使其工作为>>
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'