LeeReamond
V2EX  ›  问与答

求一个 Python 连接 Oracle 的范例,有红包奉上!

  •  
  •   LeeReamond · Dec 25, 2020 · 2007 views
    This topic created in 2139 days ago, the information mentioned may be changed or developed.

    业务需要试着使用 python 异步连接 oracle,折腾了半天没连上。

    有没有大佬提供一些范例脚本?

    (有 mysql 基础,没用过 oracle,目前已经安装完毕 oracle 11gR2,在 navicat 中成功连接。由于业务需要异步连接,观察 python 有 odbc 库支持异步连接 oracle,试了试没有调试成功)

    有没有大佬加 QQ 教学一下连接配置+写几句范例脚本的?

    我需要创建表、删除表、批量增、批量删、批量改,查询(参数需要经过标准化)这六条语句的范例。(实在不行同步也行,我自己做一些异步封装,但最好是用标准库里的那个异步 odbc)。

    有偿!有小红包奉上!

    QQ:MzA5NzE1NDQyMQ==

    4 replies  •  2020-12-25 18:58:38 +08:00
    WEAlex
    WEAlex
    Dec 25, 2020
    1
    import cx_Oracle;

    db=cx_Oracle.connect('username','password','host/orcl');

    cr = db.cursor();

    sql='select sysdate from dual';

    cr.execute(sql);

    rs = cr.fetchall();

    db.close();
    black11black
    black11black
    Dec 25, 2020
    3
    楼主这个需求我连了一下也没连上,哈哈
    fub2020
    fub2020
    Dec 25, 2020 via iPhone
    4
    说个思路吧
    用 C 语言去实现功能,在让 python 去调用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1953 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 16:46 · PVG 00:46 · LAX 08:46 · JFK 11:46
    ♥ Do have faith in what you're doing.