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