check connections to database postgres code example Example: check connections to database postgres SELECT * FROM pg_stat_activity WHERE datname='db_name';