python3.4 访问 oracle11g

python代码简洁,准备利用其读取数据库中数据,生成csv文件,然后导入到另一个库中,因两台数据库网络不通;本次先测试oracle的代码。


下载相应的库cx_Oracle-5.2.1-11g.win-amd64-py3.4,与python版本一致,同时注意操作系统的位数,我这里是64位系统。网址:https://pypi.python.org/pypi/cx_Oracle/5.2.1

import cx_Oracle

conn = cx_Oracle.connect('userName/pwd@192.168.0.192/orcl')
cur = conn.cursor()
cur.execute("select user_name,user_real_name,update_date from sys_user where id = '10000'")
row =cur.fetchone() #返回元祖

for f in row:
    print(f)

cur.close()
conn.close()

代码确实简洁。不过显然是测试代码,没有通用性,查找下有没有java中类似的dbutils、mybatis之类工具,在别人肩膀上做点实用工具;google下,确实有,记录如下供参考。

SQLAlchemy

SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.

Django

Django for web applications, exploiting its built-in ORM capabilities.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值