python导入oracle数据的方法

本文实例讲述了python导入oracle数据的方法。分享给大家供大家参考。具体如下:

import cx_oracle
dns_tns=cx_oracle.makedsn(“192.168.0.288″,1521,”skynet”)
print dns_tns
con = cx_oracle.connect(‘alibaba’, ‘zhimakamen’, dns_tns)
cur=con.cursor()
for index,line in enumerate(file(“f2.csv”)):
sql=”””insert into iq_data_b011f8286a1b2000a
(field1,field2,field3,field4) values (“””
for fields in (line.split(“,”)):
sql=sql+”‘”+fields+”‘,”
cur.execute(sql[:-1]+”)”)
con.commit()
con.close()

希望本文所述对大家的python程序设计有所帮助。

Posted in 未分类

发表评论