import pymysql
db = pymysql.connect("0.0.0.0","root","123456","x")
cursor = db.cursor()
cursor.execute('select count(*) from TIJJ_DEFAULTINFO')
cursor.fetchall()
# ((94,),)
from DBUtils.PooledDB import PooledDB
import pymysql
c_mysql = '0.0.0.0,root,123456,x'
[c1, c2, c3, c4] = c_mysql.split(',')
pool2 = PooledDB(creator=pymysql, maxconnections=16, mincached=5, blocking=True, host=c1, user=c2, passwd=c3, db=c4, port=3306)
print('池子目前有', len(pool2._idle_cache))
db1 = pool2.connection()
cursor1 = db1.cursor()
cursor1.execute('show tables;')
print('池子目前有', len(pool2._idle_cache))
db2 = pool2.connection()
cursor2 = db2.cursor()
cursor2.execute('show tables;')
print('池子目前有', len(pool2._idle_cache))
# 池子目前有 5
# 池子目前有 4
# 池子目前有 3
from DBUtils.PersistentDB import PersistentDB
import pymysql
c_mysql = '0.0.0.0,root,123456,x'
[c1, c2, c3, c4] = c_mysql.split(',')
pool2 = PersistentDB(creator=pymysql, threadlocal=None, host=c1, user=c2, passwd=c3, db=c4, port=3306)
db1 = pool2.connection()
cursor1 = db1.cursor()
cursor1.execute('show tables;')
print('End')
db2 = pool2.connection()
cursor2 = db2.cursor()
cursor2.execute('show tables;')
print('End')
# End
# End