Answer a question

I'm trying to increase the connection pool size when connecting from Python Flask application to MySQL. To start with, I got an error "TimeoutError: QueuePool limit of size 10 overflow 10 reached" so tried to increase the pool size by passing session_options as shown below. Now I get an error "TypeError: init() got an unexpected keyword argument 'pool_size'". Any ideas on how I can increase the pool size?

from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app, session_options={'pool_size': 20})

Answers

you can set SQLALCHEMY_POOL_SIZE configuration key: https://pythonhosted.org/Flask-SQLAlchemy/config.html#configuration-keys

app = Flask(__name__)
app.config['SQLALCHEMY_POOL_SIZE'] = 20
db = SQLAlchemy(app)
Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐