InterSystems IRIS Python 使用 DB-API连接 ,比odbc简单

1、下载安装驱动

同步的gitee下载地址::于光/iris-driver-distribution - Gitee.com

pip install intersystems_irispython-version-py3-none-any.whl

 

2、python代码测试

 

import iris as dbapi
conn = dbapi.connect(hostname='127.0.0.1', port=1972, namespace='xxx', username='xx', password='xx')

# Define the SQL query
sql = f"select top 10 * from xx.xx"

try:
    # Create a cursor
    cursor = conn.cursor()

    # Set the arraysize for fetching multiple rows at once
    cursor.arraysize = 20

    # Execute the SQL query
    cursor.execute(sql)

    # Fetch all rows
    rows = cursor.fetchall()

    # Print the rows
    for row in rows:
        print(row)

    # Close the cursor
    cursor.close()

except Exception as e:
    print(f"An error occurred: {e}")

finally:
    # Close the connection
    conn.close()

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-16 18:22:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-16 18:22:02       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-16 18:22:02       58 阅读
  4. Python语言-面向对象

    2024-07-16 18:22:02       69 阅读

热门阅读

  1. 【C语言高级指导】错误处理

    2024-07-16 18:22:02       22 阅读
  2. Unity七大原则

    2024-07-16 18:22:02       19 阅读
  3. C++ 入门14:STL 容器之向量(vector)

    2024-07-16 18:22:02       25 阅读
  4. GO—CPU占用高问题归类

    2024-07-16 18:22:02       20 阅读
  5. git流程及命令

    2024-07-16 18:22:02       16 阅读
  6. vue3上传图片,进行图片压缩(image-compressor.js)

    2024-07-16 18:22:02       22 阅读
  7. 图片裁剪-cropperjs

    2024-07-16 18:22:02       22 阅读
  8. 聊聊自动驾驶中的路径和轨迹

    2024-07-16 18:22:02       22 阅读
  9. python利用ffmpeg实现视频流的下载,并分段保存

    2024-07-16 18:22:02       24 阅读
  10. virsh命令使用笔记

    2024-07-16 18:22:02       23 阅读
  11. 变分法笔记3:多变量函数

    2024-07-16 18:22:02       17 阅读
  12. CFU-Net

    CFU-Net

    2024-07-16 18:22:02      22 阅读