xxxxxxxxxx
import psycopg2
try:
# Establish a connection to the Postgres database
conn = psycopg2.connect(dbname='your_database', user='your_user', password='your_password', host='your_host', port='your_port')
conn.close()
print("Postgres is running")
except psycopg2.OperationalError:
print("Postgres is not running")