How to write pandas dataframe to oracle database using to_sql?

后端 未结 1 782
轮回少年
轮回少年 2021-02-06 02:19

I\'m a new oracle learner. I\'m trying to write a pandas dataframe into an oracle table. After I have made research online, I found the code itself is very simple, but I don\'t

相关标签:
1条回答
  • 2021-02-06 02:57

    I've seen similar questions on SO - it happens when you try to write to Oracle DB using connection object created by cx_Oracle.

    Try to create connection using SQL Alchemy:

    import cx_Oracle
    from sqlalchemy import types, create_engine
    
    conn = create_engine('oracle+cx_oracle://scott:tiger@host:1521/?service_name=hr')
    
    df.to_sql('TEST', conn, if_exists='replace')
    
    0 讨论(0)
提交回复
热议问题