What is the best solution for database connection pooling in python?

前端 未结 8 1520
青春惊慌失措
青春惊慌失措 2020-11-28 23:09

I have developed some custom DAO-like classes to meet some very specialized requirements for my project that is a server-side process that does not run inside any kind of fr

相关标签:
8条回答
  • 2020-11-28 23:30

    Use DBUtils, simple and reliable.

    pip install DBUtils
    
    0 讨论(0)
  • 2020-11-28 23:34

    Making your own connection pool is a BAD idea if your app ever decides to start using multi-threading. Making a connection pool for a multi-threaded application is much more complicated than one for a single-threaded application. You can use something like PySQLPool in that case.

    It's also a BAD idea to use an ORM if you're looking for performance.

    If you'll be dealing with huge/heavy databases that have to handle lots of selects, inserts, updates and deletes at the same time, then you're going to need performance, which means you'll need custom SQL written to optimize lookups and lock times. With an ORM you don't usually have that flexibility.

    So basically, yeah, you can make your own connection pool and use ORMs but only if you're sure you won't need anything of what I just described.

    0 讨论(0)
提交回复
热议问题