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/[email protected]/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()
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.