import psycopg2 from base import Base class Postgres(Base): def __init__(self, database, user, password, host, port): if port is None: port = 5432 try: self.conn = psycopg2.connect("dbname={0} user={1} password={2} host={3} port={4}".format(database, user, password, host, port)) except psycopg2.Error as e: raise Exception(e)