How to preserve database connection in a python web server

后端 未结 3 917
滥情空心
滥情空心 2020-12-25 14:22

I am looking at the Flask tutorial, and it suggests to create a new database connection for each web request. Is it the right way to do things ? I always thought that the da

3条回答
  •  一个人的身影
    2020-12-25 15:14

    Is creating a new connection each request the way to go? No. For large applications we strongly recommend using SQLAlchemy (which can have a connection pool configured), even if you are not interested in the ORM. The docs have a section on that actually: http://flask.pocoo.org/docs/patterns/sqlalchemy/#sql-abstraction-layer

提交回复
热议问题