LeeReamond
V2EX  ›  问与答

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

  •  
  •   LeeReamond · Dec 25, 2020 · 1674 views
    This topic created in 1967 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
        1
    WEAlex  
       Dec 25, 2020
    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
        3
    black11black  
       Dec 25, 2020
    楼主这个需求我连了一下也没连上,哈哈
    fub2020
        4
    fub2020  
       Dec 25, 2020 via iPhone
    说个思路吧
    用 C 语言去实现功能,在让 python 去调用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2986 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 315ms · UTC 12:52 · PVG 20:52 · LAX 05:52 · JFK 08:52
    ♥ Do have faith in what you're doing.