您的位置:首页 > 数据库 > Oracle

python3.3.5+oracle+windows

2016-06-01 21:44 477 查看
安装文件windows,安装了有些版本不兼容,就安装了python3.3.5和cx_Oracle-5.1.3-11g.win32-py3.3.exe 以及oracle监听器

把oci.dll , oraocci11.dll,oraociei11.dll放在安装目录 C:\Python33\Lib\site-packages下 如图





编写代码测试:

'''
连接数据库 oracle
'''
import cx_Oracle  as db
#
username = "xx_ss"
passwd = "xx"
host = "192.168.176.122"
port = "1521"
sid = "orcl"
dsn = db.makedsn(host, port, sid);
con=db.connect (username,passwd,dsn)
cursor = con.cursor()
sql='select * from T_USER'
cursor.execute (sql)
result = cursor.fetchall()
print("Total: " + str(cursor.rowcount))

for row in result:
print  (row)
cursor.close()
con.close()


C:\Python33\python.exe C:/Users/xiefg/PycharmProjects/test/test.py
Total: 10
(2, 'ding', '12345', 'ding@qq.com')
(3, 'wang', '12345', 'wang@qq.com')
(4, 'zhao', '12345', 'zhao@qq.com')
(5, '张三', '12345', 'zhang@qq.com')
(6, 'li', '12345', 'li@qqq.com')
(7, 'jiang', '12345', 'jiang@qq.com')
(8, 'zheng', '12345', 'zheng@qq.com')
(9, 'liu', '12345', 'liu@qq.com')
(10, 'yu', '12345', 'yu@qq.com')
(11, 'gu', '12345', 'gu@qq.com')

Process finished with exit code 0


安装文件:http://download.csdn.net/detail/u010011737/9538336
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: