为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。 【DM版本】:DM8 【操作系统】:WINDOW 7 【CPU】: 【问题描述】*: 通过dmPython.connect可以连接达梦数据库,如果我想要使用连接池的方式连接达梦数据库,就像mysql的PooledDB一样,如何实现?每次使用时从连接池取一个连接,不用时放回去。
可以使用DBUtils的数据库链接池PooledDB pip install DBUtils==1.3
import dmPython from DBUtils.PooledDB import PooledDB pool = PooledDB(creator=dmPython, mincached=50,maxcached=100, server='192.168.1.118', port=5236, user='SYSDBA', password='123456789') conn = pool.connection() cur = conn.cursor() SQL = "select username from dba_users" r = cur.execute(SQL) r = cur.fetchall() cur.close() conn.close()
可以使用DBUtils的数据库链接池PooledDB
pip install DBUtils==1.3