xxxxxxxxxx
> which psql
check if you get any o/p
if you get o/p => postgresql is installed!
xxxxxxxxxx
import subprocess
def check_postgres_installed():
try:
subprocess.run(["pg_config", "--version"], check=True)
print("PostgreSQL is installed.")
except FileNotFoundError:
print("PostgreSQL is not installed.")
except subprocess.CalledProcessError:
print("PostgreSQL is not installed.")
check_postgres_installed()