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!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.