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=%s user=%s password=%s host=%s port=%d" % (database, user, password, host, port)) except psycopg2.Error as e: raise Exception(e)