python 模块 DButils

Posted Anec

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 模块 DButils相关的知识,希望对你有一定的参考价值。

 

# DButils 为了解决多客户端都需要操作数据库的问题.
# import pymysql
# from DBUtils.PooledDB import PooledDB
#
# POOL = PooledDB(creator=pymysql,
#                 mincached=2,
#                 maxcached=5,
#                 maxshared=3,
#                 maxconnections=6,
#                 blocking=True,
#                 maxusage=None,
#                 ping=4,
#                 host=‘172.16.2.106‘,
#                 port=3306,
#                 user=‘root‘,
#                 password=‘123456‘,
#                 database=‘anec‘,
#                 charset=‘utf8‘
#                 )
#
# coon = POOL.connection()
# cursor = coon.cursor(cursor=pymysql.cursors.DictCursor)

# info_msg = {
#     ‘cx‘:‘select * from text where id=1‘,
#     ‘cr‘:‘insert into text(id,name,phone,enail) values(2,"alex","123123213","[email protected]")‘
# }

# 查询数据
# cursor.execute(‘select * from text ‘)
# ret = cursor.fetchall()

# 增加数据
# cursor.execute(‘insert into text(id,name,phone,enail) values(2,"alex","123123213","[email protected]")‘)
# coon.commit()

#
# 删除一条数据
# cursor.execute(‘delete from text where id=2‘)
# coon.commit()

# 修改数据
# cursor.execute(‘update text set phone = 18711068587 where id=1‘)
# coon.commit()

# cursor.execute(‘select * from text‘)
# ret = cursor.fetchall()
# coon.close()
# print(ret)

 

以上是关于python 模块 DButils的主要内容,如果未能解决你的问题,请参考以下文章

Python数据库连接池DBUtils

Python数据库连接池DBUtils

Python数据库连接池DBUtils

Python数据库连接池DBUtils

Python数据库连接池---DBUtils

Python的数据库连接池DBUtils