Python导入oracle数据的方法

yipeiwu_com5年前Python基础

本文实例讲述了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程序设计有所帮助。

相关文章

Python常用模块介绍

python除了关键字(keywords)和内置的类型和函数(builtins),更多的功能是通过libraries(即modules)来提供的。 常用的libraries(module...

Python中反射和描述器总结

反射 在Python中,能够通过一个对象,找出type、class、attribute或者method的能力,成为反射。 函数与方法 内建函数: getattr(object,name[...

解决Python下imread,imwrite不支持中文的问题

由以下函数代替该功能: def cv_imread(file_path): cv_img=cv2.imdecode(np.fromfile(file_path,dtype=np.u...

python操作cfg配置文件方式

*.cfg文件一般是程序运行的配置文件,python为读写常见配置文件提供了一个ConfigParser模块,所以在python中解析配置文件相当简单,下面就举例说明一下具体的操作方法。...

Python 脚本拉取 Docker 镜像问题

Python 脚本拉取 Docker 镜像问题

好久没有介绍小工具了,今天碰到一个,简单粗糙但是有用的一个,这个工具有多简单粗糙呢?证据有二: 连 Python shebang 都没有; 简单到原创 300 字都很难凑够。 言归正传:...