check connections to database postgres 1

check connections to database postgres

SELECT * FROM pg_stat_activity WHERE datname='db_name';

Here is what the above code is Doing:
1. Connect to the database
2. Create a cursor object
3. Execute the query
4. Fetch the results
5. Close the connection

Similar Posts