def get_ogr_db_string():
db = connections.databases['<STR_LIT:default>']<EOL>drivers = {<EOL>'<STR_LIT>': ('<STR_LIT>', "<STR_LIT>", '<STR_LIT:U+0020>'),<EOL>'<STR_LIT>': ('<STR_LIT>', '<STR_LIT>', '<STR_LIT:U+002C>'),<EOL>'<STR_LIT>': ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>}<EOL>db_engine = db['<STR_LIT>']<EOL>if db_engine not in drivers:<EOL><INDENT>return None<EOL><DEDENT>drv_name, db_str, param_sep = drivers[db_engine]<EOL>try:<EOL><INDENT>Driver(drv_name)<EOL><DEDENT>except GDALException:<EOL><INDENT>return None<EOL><DEDENT>if db['<STR_LIT>'] == "<STR_LIT>":<EOL><INDENT>return None<EOL><DEDENT>params = [db_str % {'<STR_LIT>': db['<STR_LIT>']}]<EOL>def add(key, template):<EOL><INDENT>value = db.get(key, None)<EOL>if value:<EOL><INDENT>params.append(template % value)<EOL><DEDENT><DEDENT>add('<STR_LIT>', "<STR_LIT>")<EOL>add('<STR_LIT>', "<STR_LIT>")<EOL>add('<STR_LIT>', "<STR_LIT>")<EOL>add('<STR_LIT>', "<STR_LIT>")<EOL>return param_sep.join(params)<EOL>
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.