Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Convert python datetime to timestamp and insert in oracle database using to_sql

4f18d79e-4bfd-461b-b351-f6ccf5b5fd13Nov 22 2018 — edited Nov 23 2018

import sqlalchemy as sa

import datetime

import itertools

...

oracle_db = sa.create_engine('oracle://username:password@host:port/database')

connection= oracle_db.connect()

dat_ult_alt = datetime.datetime.now()

df_plano['DAT_ULT_ALT'] = pd.Series(list(itertools.repeat(dat_ult_alt, max)))

df_plano.to_sql('table_name', connection, if_exists='append', index=False)

I get DatabaseError: ORA-00904: "DAT_ULT_ALT": invalid identifier

How can I insert a datetime to a timestamp in oracle using to_sql from pandas with SQL Alchemy engine?

Comments

Processing

Post Details

Added on Nov 22 2018
1 comment
6,228 views