zoukankan      html  css  js  c++  java
  • python 连接ORacle11g

     

     

     一,准备软件

    (1)cx_Oracle

    (2)instantclient

    注:

    (1)instantclient是Oracle客户端,plsql称为数据库第三方可视化工具,即便装了plsql也还是要装instantclient的!!!

    (2)另外目前plsql的破解版只支持32位的instantclient,32位的instantclient连接64位的Oracle没有问题,但64位的Python却用不了!!!

    (3)plsql连接Oracle需要配置instantclient中的tnsnames.ora,而Python连接Oracle不需要配置instantclient中的tnsnames.ora。

    tnsnames.ora配置参考博文:https://blog.csdn.net/u010916338/article/details/81367551
    二,版本

    比如:

    windows             64位

    Python3.6           64位,对应Windows版本

    Oracle11g           64位

    instanceclient      64位,对应Windows版本(不用管Oracle是多少位)

    cx_oracle             64位,对应Windows版本;且对应Python版本3.6;且对应Oracle版本11g
    三,下载地址

    instantclient-basic-windows.x64-11.2.0.4.0.zip

    https://www.oracle.com/technetwork/cn/database/features/instant-client/index-092699-zhs.html

    链接:https://pan.baidu.com/s/11Zy-_iMyjKCAllD-rz-VCQ
    提取码:jtw9


    cx_Oracle-5.3-11g.win-amd64-py3.6-2.exe

    https://pypi.org/project/cx-Oracle/#files

    链接:https://pan.baidu.com/s/1JD7Kip9GfrBJn8Rzn33qfg
    提取码:m6kg

    四,安装配置

    (1)cx_Oracle-5.3-11g.win-amd64-py3.6-2.exe安装,一键到底。

    (2)系统环境变量path中添加D:instantclient_11_2
    五,连接测试

        import cx_Oracle as oracle
        db = oracle.connect('user/password@192.168.223.138:1521/service_name')
        user用户名;password密码;服务器地址+端口号;service_name服务名
        (注:在plsql连接Oracle的instanceclient中的tnsnames.ora中配置的有。但是Python连接Oracle不需要配置tnsnames.ora)
        cursor = db.cursor()
        cursor.execute('select *from student')
        data = cursor.fetchone()
        print(data)
        cursor.close()
        db.close()

    https://zh.osdn.net/projects/sfnet_cx-oracle/releases/     for oracle cx_oracle下载地址

  • 相关阅读:
    2019-8-22学习笔记---文件上传与读取
    JS字符串的操作
    JS控制台打印星星,总有你要的那一款~呐~给你小心心哦~~~❤
    DOM的操作(增删改查)
    js上传视频(jquery.form.js)
    vue单页面模板说明文档(3)
    vue单页面模板说明文档(2)
    vue单页面模板说明文档(1)
    js 通过url获取里面的参数值
    ios点击输入框,界面放大解决方案
  • 原文地址:https://www.cnblogs.com/ruiy/p/11727475.html
Copyright © 2011-2022 走看看