Python数据库连接池DBUtils.PooledDB
来源:互联网 发布:软件测试行业如何 编辑:程序博客网 时间:2024/05/22 00:52
1. 未使用连接池连接mysql
import MySQLdbconn = MySQLdb.connect(host = '127.0.0.1', user ='user1', passwd = 'your-password', db ='db1', port = 3306) cur = conn.cursor()SQL ="select * from t1"r = cur.execute(SQL)r = cur.fetchall()cur.close()conn.close()
2. 使用连接池连接mysql
# -*- coding: utf-8 -*-import MySQLdbfrom DBUtils.PooledDB import PooledDB#5为连接池里的最少连接数pool = PooledDB(MySQLdb, 5, host = '127.0.0.1', user = 'user1', passwd = 'your-password', db = 'db1', port = 3306) #后续每次需要数据库连接用connection()函数获取连接即可。conn = pool.connection() cur = conn.cursor()SQL = "select * from t1"r = cur.execute(SQL)r = cur.fetchall()cur.close()conn.close()
阅读全文
0 0
- Python数据库连接池DBUtils.PooledDB
- Python数据库连接池DBUtils.PooledDB
- DBUtils之PooledDB数据库连接池
- python学习---3(DBUtils.PooledDB)
- Python数据库连接池DBUtils
- Python数据库连接池DBUtils
- Python数据库连接池 《DBUtils用户指南》
- Python的数据库连接池DBUtils
- 数据库连接池-DBUtils
- 数据库连接池工具---DbUtils
- 数据库连接池,DBUtils,PreparedStatement介绍
- JDBC、事务、数据库连接池、DBUtils
- Python学习一:基于DBUtils和pymysql的MySQL数据库连接池封装
- 模拟的数据库连接池与DBUtils工具包
- 使用dbutils获取tomcat数据库连接池
- Transaction事件+数据库连接池dbcp&cpds&DBUtils
- 一个简单的python连接池,以及DBUtil.PooledDB的使用
- tornado.database添加PooledDB连接池功能
- postgresql常用命令
- tensorflow中文文档学习笔记(1)
- SQLServer配置管理器
- python3爬虫初探(三)之正则表达式
- Java -- 反射
- Python数据库连接池DBUtils.PooledDB
- 外部中断实验
- HDU 6211 本源勾股组 + 法里数列
- PHP快速导出excel表格
- https\SSL安全证书配置,Tomcat、nodejs、Nginx服务器安全证书配置
- Sed替换删除添加字符串
- memcpy/memset函数的c语言实现
- 网页上出现D盾拦截
- python3爬虫初探(四)之文件保存