File size: 592 Bytes
7a88b43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

from os import environ as env
from urllib.parse import quote_plus

import psycopg2

config = {
    "host": env.get("DATABASE_HOSTNAME"),
    "port": env.get("DATABASE_PORT", 5432),
    "user": env.get("DATABASE_USER", "revmigrate"),
    "pass": quote_plus(env.get("DATABASE_PASSWORD", "revmigrate")),
    "database": env.get("DATABASE_DB", "revmigrate_ai_agent_db"),
}

dsn = "postgresql://%(user)s:%(pass)s@%(host)s:%(port)s/%(db)s" % config

if __name__ == "__main__":
    try:
        db = psycopg2.connect(dsn)
    except (Exception, psycopg2.DatabaseError):
        exit(1)

    exit(0)