我正在尝试使用sqlalchemy进行阅读,然后将其插入到Oracle数据库中。pd.read\u sql\u查询工作正常,当我执行display(df)时,我得到以下结果
ldate lid lkey act__c name c_status__c cre_dt cre_by l_cre_dt l_cre_by
2020-08-12 a1234A6788qRstuYGE Test name LLC Prospect 2020-08-10 09:14:42.0 Test Usr 2020-08-12 11:48:16.0 Test Usr
2020-08-13 a1234A6788qRstuYGE Test name LLC Prospect 2020-08-10 09:14:42.0 Test Usr 2020-08-12 11:48:16.0 Test Usr
2020-10-09 a1234A6788qRstuYGE 123456789 Test name LLC Prospect 2020-08-10 09:14:42.0 Test Usr 2020-08-12 11:48:16.0 Test Usr
2020-10-10 a1234A6788qRstuYGE 123456789 Test name LLC Client 2020-08-10 09:14:42.0 Test Usr 2020-08-12 11:48:16.0 Test Usr
2020-10-10 a1234A6788qRstuYGE 200140958CONTRACT1 123456789 Test name LLC Client 2020-08-10 09:14:42.0 Test Usr 2020-10-10 18:28:24.0 Test Usr
2020-10-11 a1234A6788qRstuYGE 123456789 Test name LLC Client 2020-08-10 09:14:42.0 Test Usr 2020-08-12 11:48:16.0 Test Usr
2020-10-11 a1234A6788qRstuYGE 200140958CONTRACT1 123456789 Test name LLC Client 2020-08-10 09:14:42.0 Test Usr 2020-10-10 18:28:24.0 Test Usr
2020-11-01 a1234A6788qRstuYGE 123456789 Test name LLC Client 2020-08-10 09:14:42.0 Test Usr 2020-08-12 11:48:16.0 Test Usr
随后,当我们向sql发出df.to('test_insert',conn,if_exists='replace')时。我得到以下错误
TypeError: unhashable type: 'list'
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
test_query = """
SELECT * from TBL
"""
conn = create_engine('redshift+psycopg2://testredshitserver:1234/testdb',connect_args={'sslmode': 'prefer'})
df = pd.read_sql_query(test_query,conn)
display (df)
# Here is the issue
df.to_sql('test_insert', conn, if_exists='replace')
目前没有回答
相关问题 更多 >
编程相关推荐