关闭

python3.3.5+oracle+windows

标签: python
783人阅读 评论(0) 收藏 举报
分类:

安装文件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


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:72517次
    • 积分:1185
    • 等级:
    • 排名:千里之外
    • 原创:45篇
    • 转载:12篇
    • 译文:1篇
    • 评论:9条
    文章分类
    最新评论