当前位置:   article > 正文

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

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

1、下载安装驱动

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

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

 

2、python代码测试

  1. import iris as dbapi
  2. conn = dbapi.connect(hostname='127.0.0.1', port=1972, namespace='xxx', username='xx', password='xx')
  3. # Define the SQL query
  4. sql = f"select top 10 * from xx.xx"
  5. try:
  6. # Create a cursor
  7. cursor = conn.cursor()
  8. # Set the arraysize for fetching multiple rows at once
  9. cursor.arraysize = 20
  10. # Execute the SQL query
  11. cursor.execute(sql)
  12. # Fetch all rows
  13. rows = cursor.fetchall()
  14. # Print the rows
  15. for row in rows:
  16. print(row)
  17. # Close the cursor
  18. cursor.close()
  19. except Exception as e:
  20. print(f"An error occurred: {e}")
  21. finally:
  22. # Close the connection
  23. conn.close()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/843157
推荐阅读
相关标签
  

闽ICP备14008679号