I am using falsk SQLAlchemy with MYSQL with all default configuration(pool size and timeout)
I don't understand why do I get out of DB connections from the MYSQL DB? My server is not that heavy loaded.
Can someone please explain how the flask sql alchemy get and release DB connections?
If I have a pool thread of 20 on my apache mod_wsgi server that means by theory that i can have 20 db connection opens all the time and that's it no?
How flask sql alchemy handle close and restore those connections. Thanks
try this code
import sqlalchemy
dbhost = 'localhost' #host name
dbuser = 'root' #mysql username
dbpass = 'admin' #mysql password
dbname = 'mytable' #database name
engine = sqlalchemy.create_engine('mysql://'+dbuser+':'+dbpass+'@'+dbhost ) # connect to server
DB_URI = 'mysql://' + dbuser + ':' + dbpass + '@' + dbhost + '/' +dbname
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']=DB_URI
db = SQLAlchemy(app)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.