human
Complete this python program:
def connect(dbn, **keywords):
assistant
#Here is the Python program you requested.

    """Connects to the specified database.
    db currently must be "postgres" or "mysql".
    If DBUtils is installed, connection pooling will be used.
    """
    if (dbn == 'postgres'):
        try:
            import psycopg2 as db
        except ImportError:
            try:
                import psycopg as db
            except ImportError:
                import pgdb as db
        keywords['password'] = keywords['pw']
        del keywords['pw']
        keywords['database'] = keywords['db']
        del keywords['db']
    elif (dbn == 'mysql'):
        import MySQLdb as db
        keywords['passwd'] = keywords['pw']
        del keywords['pw']
        db.paramstyle = 'pyformat'
    elif (dbn == 'sqlite'):
        try:
            from pysqlite2 import dbapi2 as db
            db.paramstyle = 'qmark'
        except ImportError:
            import sqlite as db
        keywords['database'] = keywords['db']
        del keywords['db']
    else:
        raise UnknownDB, dbn
    ctx.db_name = dbn
    ctx.db_module = db
    ctx.db_transaction = False
    if _hasPooling:
        if ('db' not in globals()):
            globals()['db'] = PooledDB(dbapi=db, **keywords)
        ctx.db = globals()['db'].connection()
    else:
        ctx.db = db.connect(**keywords)
    ctx.dbq_count = 0
    if globals().get('db_printing'):
        def db_execute(cur, sql_query, d=None):
            'executes    an    sql    query'
            def sqlquote(obj):
                'converts    `obj`    to    its    proper    SQL    version'
                if (obj is None):
                    return 'NULL'
                elif (obj is True):
                    return "'t'"
                elif (obj is False):
                    return "'f'"
                elif isinstance(obj, datetime.datetime):
                    return repr(obj.isoformat())
                else:
                    return repr(obj)
            ctx.dbq_count += 1
            try:
                outq = (sql_query % tuple(map(sqlquote, d)))
            except TypeError:
                outq = sql_query
            print >>debug, (str(ctx.dbq_count) + ':'), outq
            a = time.time()
            out =...