python对Oracle数据库接口cx_Oracle

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)
    原文作者:九命猫幺
    原文地址: https://www.cnblogs.com/yongestcat/p/11394297.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞