human
Complete this python program:
def get_ogr_db_string():
assistant
#Here is the Python code you requested.

    """Construct the DB string that GDAL will use to inspect the database.
    GDAL will create its own connection to the database, so we re-use the
    connection settings from the Django test.
    """
    db = connections.databases['default']
    drivers = {'django.contrib.gis.db.backends.postgis': ('PostgreSQL', "PG:dbname='%(db_name)s'", '    '), 'django.contrib.gis.db.backends.mysql': ('MySQL', 'MYSQL:"%(db_name)s"', ','), 'django.contrib.gis.db.backends.spatialite': ('SQLite', '%(db_name)s', '')}
    db_engine = db['ENGINE']
    if (db_engine not in drivers):
        return None
    (drv_name, db_str, param_sep) = drivers[db_engine]
    try:
        Driver(drv_name)
    except GDALException:
        return None
    if (db['NAME'] == ':memory:'):
        return None
    params = [(db_str % {'db_name': db['NAME']})]
    def add(key, template):
        value = db.get(key, None)
        if value:
            params.append((template % value))
    add('HOST', "host='%s'")
    add('PORT', "port='%s'")
    add('USER', "user='%s'")
    add('PASSWORD', "password='%s'")
    return param_sep.join(params)