1. import pymysql
    2. db = pymysql.connect("0.0.0.0","root","123456","x")
    3. cursor = db.cursor()
    4. cursor.execute('select count(*) from TIJJ_DEFAULTINFO')
    5. cursor.fetchall()
    6. # ((94,),)
    7. from DBUtils.PooledDB import PooledDB
    8. import pymysql
    9. c_mysql = '0.0.0.0,root,123456,x'
    10. [c1, c2, c3, c4] = c_mysql.split(',')
    11. pool2 = PooledDB(creator=pymysql, maxconnections=16, mincached=5, blocking=True, host=c1, user=c2, passwd=c3, db=c4, port=3306)
    12. print('池子目前有', len(pool2._idle_cache))
    13. db1 = pool2.connection()
    14. cursor1 = db1.cursor()
    15. cursor1.execute('show tables;')
    16. print('池子目前有', len(pool2._idle_cache))
    17. db2 = pool2.connection()
    18. cursor2 = db2.cursor()
    19. cursor2.execute('show tables;')
    20. print('池子目前有', len(pool2._idle_cache))
    21. # 池子目前有 5
    22. # 池子目前有 4
    23. # 池子目前有 3
    24. from DBUtils.PersistentDB import PersistentDB
    25. import pymysql
    26. c_mysql = '0.0.0.0,root,123456,x'
    27. [c1, c2, c3, c4] = c_mysql.split(',')
    28. pool2 = PersistentDB(creator=pymysql, threadlocal=None, host=c1, user=c2, passwd=c3, db=c4, port=3306)
    29. db1 = pool2.connection()
    30. cursor1 = db1.cursor()
    31. cursor1.execute('show tables;')
    32. print('End')
    33. db2 = pool2.connection()
    34. cursor2 = db2.cursor()
    35. cursor2.execute('show tables;')
    36. print('End')
    37. # End
    38. # End