

@signalcommand
def handle(self, *args, **options):
    router = options.get('router')
    dbinfo = settings.DATABASES.get(router)
    if (dbinfo is None):
        raise CommandError(('Unknown database router %s' % router))
    engine = dbinfo.get('ENGINE').split('.')[(- 1)]
    dbuser = dbinfo.get('USER')
    dbpass = dbinfo.get('PASSWORD')
    dbname = dbinfo.get('NAME')
    dbhost = dbinfo.get('HOST')
    dbclient = socket.gethostname()
    if (not dbhost):
        dbhost = 'localhost'
    if (engine == 'mysql'):
        sys.stderr.write('-- WARNING!: https://docs.djangoproject.com/en/dev/ref/databases/#collation-settings\n-- Please read this carefully! Collation will be set to utf8_bin to have case-sensitive data.\n')
        print(('CREATE DATABASE %s CHARACTER SET utf8 COLLATE utf8_bin;' % dbname))
        print(("GRANT ALL PRIVILEGES ON %s.* to '%s'@'%s' identified by '%s';" % (dbname, options, dbclient, dbpass)))
    elif (engine == 'postgresql_psycopg2'):
        if options.get('drop'):
            print(('DROP DATABASE IF EXISTS %s;' % (dbname,)))
            print(('DROP USER IF EXISTS %s;' % (dbuser,)))
        print(("CREATE USER %s WITH ENCRYPTED PASSWORD '%s' CREATEDB;" % (dbuser, dbpass)))
        print(('CREATE DATABASE %s WITH ENCODING \'UTF-8\' OWNER "%s";' % (dbname, dbuser)))
        print(('GRANT ALL PRIVILEGES ON DATABASE %s TO %s;' % (dbname, dbuser)))
    elif (engine == 'sqlite3'):
        sys.stderr.write('-- manage.py syncdb will automatically create a sqlite3 database file.\n')
    else:
        sys.stderr.write(("-- Don't know how to handle '%s' falling back to SQL.\n" % engine))
        print(('CREATE DATABASE %s;' % dbname))
        print(('GRANT ALL PRIVILEGES ON DATABASE %s to %s' % (dbname, dbuser)))

dataset/ETHPy150Open django-extensions/django-extensions/django_extensions/management/commands/sqlcreate.py Command.handle/VarMisuse@171/338 `dbuser`->`options`