3

I have this code that sends CSVs to Oracle but it's slower than molasses in January. I'd like to use odo but the documentation is scarce for this exact type of situation (data from CSV to Oracle). I'm not married to Pandas, so if it's better to not use it than that's fine with me.

import pandas as pd
import pandas.io.sql as psql
from sqlalchemy import create_engine
import cx_Oracle as cx

engine = create_engine('oracle+cx_oracle://schema:'+pwd+'@server:port/service_name'
,encoding='latin1')

name='table'
path=r'path_to_folder'
filelist = os.listdir(path) 

for file in filelist:
    df = pd.read_csv(pathc+'\\'+file,encoding='latin1',index_col=0)
    df=df.astype('unicode')
    df['date'] = pd.to_datetime(df['date'])
    df['date'] = pd.to_datetime(df['Contract_EffDt'],format='%YYYY-%mm-%dd')
    df.to_sql(name, engine, if_exists = 'append')

Thanks in advance!

Dance Party2
  • 7,214
  • 17
  • 59
  • 106

0 Answers0