作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个像这样的mysql连接池:
database = PooledMySQLDatabase('test', max_connections=10,
**{'host': 'localhost', 'port': 3306,
'user': 'root', 'password': ''})
class BaseModel(Model):
class Meta:
database = database
class Tb1(BaseModel):
point_id = PrimaryKeyField()
class Meta:
db_table = 'tb1'
但是,当我在数据库中手动插入记录或删除记录时,在我的程序中,选择结果没有改变。
while True:
database.connect()
tb_list = Tb1.select()
print(len(tb_list))
database.close()
import time
time.sleep(2)
当我将 PooledMySQLDatabase 替换为 MySQLDatabase 时,结果正常。在我的项目中,我想使用多线程,所以我需要创建一个mysql池。
非常感谢
最佳答案
没有缓存,没有缓冲区。它与事务管理有关。只要确保您在事务中运行语句就应该没问题。
多线程应用程序不需要 peewee 的池。即使没有池,Peewee 也能正确管理每个线程的连接。
关于python - peewee PooledMySQL数据库有缓存或缓冲区吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34764266/
我是一名优秀的程序员,十分优秀!