Search code examples
python-2.7peewee

Counting Active connections in peewee ORM


I am using Python's peewee ORM with MYSQL. I want to list the active connections for the PooledDatabase. Is there any way to list..?


Solution

  • What do you mean "active"? Active as in being "checked out" by a thread, or active as in "has a connection to the database"?

    For the first, you would just do pooled_db._in_use.

    For the second, it's a little trickier -- basically it will be the combination of pooled_db._in_use (a dict) and pooled_db._connections (a heap).