我已经查看了各种答案,并且没有一种语法对我有用。我在Python 3.5中使用以下代码:
from sqlalchemy import text
import pandas as pd
import cx_Oracle
conn = cx_Oracle.connect(os.getlogin()) --this part works fine
sql = text('select var1 as "nameM" ' \
'from Table1 where ' \
'col1 = :le ' \
'and col2 = :t ' \
'and col3Date between :stDt and :enDt')
data = pd.read_sql(sql, conn, params = {'le':'S', 't':'HEN', 'stDt':'06-NOV-17', 'enDt':'24-NOV-17'})
我也尝试了各种其他配置,并且我不断收到以下错误:
pandas.io.sql.DatabaseError: Execution failed on sql XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: expecting string or bytes object
答案 0 :(得分:0)