The most exact way to determine how many database connections a Python process is using is to use netstat. If you need a quick number and don't care about internals, that's your number.

Next, if you're in the Python process and have specific pool / engine to look at, it can give you an estimate using the checkedin() and checkedout() accessors.

You can get a more exact number within process by using event handlers on the Pool itself, including tracking the "connect" event (http://docs.sqlalchemy.org/en/rel_1_0/core/events.html#sqlalchemy.events.PoolEvents.connect). However, SQLA doesn't yet provide an event for close(), so that approach requires a monkeypatch of the close() method. If you want to go the in-process route, we use a tool called connmon https://bitbucket.org/zzzeek/connmon which does this patch in order to get a graphical view of all connection activity in real time; here's a screenshot: https://bitbucket.org/zzzeek/connmon/src/954df26404d5533cf6a969b673e87b66ffe02a85/screenshot.png?fileviewer=file-view-default.

But quick and easy, use netstat.





On 03/16/2016 05:23 PM, Dave Ekhaus wrote:
Hi All

     Is there a way to determine the exact number of open db connections
in SQLAlchemy's connection pool ?

Thanks
Dave

--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to