python对Oracle数据库的操作用cx_Oracle库
操作简单,例如
#例子
import cx_Oracle
con = cx_Oracle.connect("pythondemo/welcome@192.168.188.11:1521/std1")
cur = con.cursor()
rows = [ (1, "First" ), (2, "Second" ),
(3, "Third" ), (4, "Fourth" ),
(5, "Fifth" ), (6, "Sixth" ),
(7, "Seventh" ) ]
cur.execute("truncate table mytab")
cur.executemany("insert into mytab(id, data) values (:1, :2)", rows)
con.commit()
cur.execute('select * from mytab')
res = cur.fetchall()
print(res)
cur.close()
con.close()
例2
import pandas as pd
import cx_Oracle
con = cx_Oracle.connect("scott","tiger","192.0.2.21:1521/std1")
d = pd.read_sql('select * from emp',con)