The Python SQL Toolkit and Object Relational Mapper
本仓库是基于 sqlalchemy commit fb81f9c 基础上进行修改,主要新增两个特性:
- 新增 py_opengauss 驱动支持(需安装
pip install py-opengauss==1.3.6
) - openGauss 数据库支持多主机连接,自动选主库
这里单独演示 opengauss 数据库多主机连接方式用法:
检查 py-opengauss 是否安装以及版本大于1.3.6
$ pip list | grep py-opengauss py-opengauss 1.3.6
使用 sqlalchemy 创建连接
from sqlalchemy import create_engine # 初始化数据库连接: engine = create_engine('postgresql+pyopengauss://user:password@host1:port1,host2:port2/db')
Latest documentation is at:
https://www.sqlalchemy.org/docs/
Full documentation for installation is at Installation.
Please refer to the SQLAlchemy Community Guide.
Above all, SQLAlchemy places great emphasis on polite, thoughtful, and constructive communication between users and developers. Please see our current Code of Conduct at Code of Conduct.
SQLAlchemy is distributed under the MIT license.