zoukankan      html  css  js  c++  java
  • Pycharm中Python3连接Oracle

    一、环境配置:
    系统:win7、10 (64位)
    软件:1.Python3.7.2 (64位)
    2.instantclient-basic-windows.x64-11.2.0.4.0.zip(64位) --这个必须要安装
         百度网盘下载地址:https://pan.baidu.com/s/1wuOUIT7wmnIm5iq-50fFvQ 提取码:6f8g
    3.Oracle 11gR2 (64位)
    最好要保持Python、instantclient和Oracle位数一致(我本机安装的都是64位的)!!!

    二、步骤:
    2.1 把instantclient-basic-windows.x64-11.2.0.4.0.zip解压到某一目录并把目录配置到系统环境变量Path中
    2.2 下载安装vcredist_x64.exe,安装好后重启电脑,必须要重启一下
    2.3 安装cx_Oracle: pip install cx_Oracle

    三、测试:

    import cx_Oracle
    class My_plsq:
        def my_cha(self,my_sql_c):
            try:
                conn = cx_Oracle.connect("连接名","密码","localhost/orcl")
                cursor = conn.cursor()
                cursor.execute(my_sql_c)
                all_data = cursor.fetchall()
                oo = list(all_data[0])
                return oo
            except cx_Oracle.DatabaseError:
                return print("无效的SQL语句")
    if __name__ == '__main__':
        a=My_plsq()
        l=a.my_cha("SELECT * FROM 表名")
    print(l)

    亲测有效

  • 相关阅读:
    Codeforces 543E. Listening to Music
    UOJ #138. 【UER #3】开学前的涂鸦
    bzoj 3569: DZY Loves Chinese II
    bzoj 2428: [HAOI2006]均分数据
    bzoj 4589: Hard Nim
    UOJ #119. 【UR #8】决战圆锥曲线
    spoj5973
    codeforces555E
    poj1275
    bzoj4152
  • 原文地址:https://www.cnblogs.com/Mr-Simple001/p/10516148.html
Copyright © 2011-2022 走看看