Oracle Connection

In [2]:
import getpass
username = input("Enter your Userid: \n")
password = getpass.getpass("Enter your Password: \n")
Enter your Userid: 
sdf
Enter your Password: 
········
In [ ]:
from sqlalchemy import *
conn_str = 'oracle://%s[%s]:%s@%s' % (username, database_schema, password, database_instance)
# conn_str = 'oracle://username[proxy1]:password@db

engine = create_engine(conn_str)
CONN = engine.connect()
CONN.execute("Alter session enable parallel dml")
In [ ]:
query = """
    create table table1
    as
    select * from table2
"""
CONN.execute(query)
In [3]:
import pandas as pd
df = pd.read_csv('data.csv', dtype={'NAME': str,'GENDER': str,'ADDRESS': str})
print(df)
  NAME  AGE GENDER ADDRESS
0  abc   10      m    add1
1  xyz   20      f    add2
In [ ]:
df.to_sql('table1', CONN, index=False, if_exists='replace',
                  dtype={
                      'NAME': types.VARCHAR(100),
                      'GENDER': types.VARCHAR(10),
                      'ADDRESS': types.VARCHAR(100)
                  })
www.000webhost.com