<s> import MySQLdb <EOL> import psycopg2 <EOL> import os <EOL> from wsgi import * <EOL> def create_dbs ( ) : <EOL> print ( "<STR_LIT>" ) <EOL> django_settings = __import__ ( os . environ [ '<STR_LIT>' ] , fromlist = '<STR_LIT>' ) <EOL> print ( "<STR_LIT>" ) <EOL> databases = django_settings . DATABASES <EOL> for name , db in databases . iteritems ( ) : <EOL> host = db [ '<STR_LIT>' ] <EOL> user = db [ '<STR_LIT>' ] <EOL> password = db [ '<STR_LIT>' ] <EOL> port = db [ '<STR_LIT>' ] <EOL> db_name = db [ '<STR_LIT>' ] <EOL> db_type = db [ '<STR_LIT>' ] <EOL> if db_type . endswith ( '<STR_LIT>' ) : <EOL> print '<STR_LIT>' % ( db_name , host ) <EOL> db = MySQLdb . connect ( user = user , <EOL> passwd = password , <EOL> host = host , <EOL> port = port ) <EOL> cur = db . cursor ( ) <EOL> print ( "<STR_LIT>" ) <EOL> cur . execute ( """<STR_LIT>""" , ( db_name , ) ) <EOL> results = cur . fetchone ( ) <EOL> if not results : <EOL> print ( "<STR_LIT>" % db_name ) <EOL> sql = """<STR_LIT>""" % ( db_name , ) <EOL> print ( "<STR_LIT>" % sql ) <EOL> cur . execute ( sql ) <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> elif db_type . endswith ( '<STR_LIT>' ) : <EOL> print '<STR_LIT>' % ( db_name , host ) <EOL> con = psycopg2 . connect ( host = host , user = user , password = password , port = port , database = '<STR_LIT>' ) <EOL> con . set_isolation_level ( <NUM_LIT:0> ) <EOL> cur = con . cursor ( ) <EOL> try : <EOL> cur . execute ( '<STR_LIT>' % db_name ) <EOL> except psycopg2 . ProgrammingError as detail : <EOL> print detail <EOL> print '<STR_LIT>' <EOL> else : <EOL> print ( "<STR_LIT>" . format ( db_type ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import sys <EOL> print ( "<STR_LIT>" ) <EOL> create_dbs ( ) <EOL> print ( "<STR_LIT>" ) </s>
