def psycopg2_connect(dsn=None, *args, **kwargs):
    if dsn is None:
        c_host = kwargs.pop("c_host", None) or "localhost"
        c_port = kwargs.pop("c_port", None) or "5432"
        c_dbname = kwargs.pop("c_dbname", None) or "postgres"
        c_user = kwargs.pop("c_user", None) or ""
        c_password = kwargs.pop("c_password", None) or ""
        dsn = "host=%s port=%s dbname=%s user=%s password=%s" % (c_host, c_port, c_dbname, c_user, c_password)
    tracer = kwargs.pop("tracer", None)
    trace_stmt = kwargs.pop("trace_stmt", None)
    if tracer:
        conn = psycopg2.connect(dsn, *args, connection_factory=TracingConnection, **kwargs)
        conn.set_tracer(tracer, trace_stmt)
    else:
        conn = psycopg2.connect(dsn, *args, **kwargs)
    return conn
dataset/ETHPy150Open ooici/pyon/pyon/datastore/postgresql/pg_util.py/psycopg2_connect/original