fix broken MySQL quoting

This commit is contained in:
Jan Dittberner 2015-01-01 23:14:37 +01:00
parent 4ed81c29e6
commit 2a638481d1
1 changed files with 6 additions and 9 deletions

View File

@ -105,14 +105,12 @@ def create_mysql_database(dbname, username):
curs = conn.cursor()
curs.execute(
"""
CREATE DATABASE %(dbname)s CHARACTER SET utf8 COLLATE utf8_german_ci
""",
{'dbname': dbname})
CREATE DATABASE `%(dbname)s` CHARACTER SET utf8 COLLATE utf8_german_ci
""" % {'dbname': dbname})
curs.execute(
"""
GRANT ALL PRIVILEGES ON %(dbname)s.* TO %(username)s@'%%'
""",
{'dbname': dbname, 'username': username})
GRANT ALL PRIVILEGES ON `%(dbname)s`.* TO %%(username)s@'%%%%'
""" % {'dbname': dbname}, {'username': username})
conn.commit()
return dbname
@ -133,8 +131,7 @@ def delete_mysql_database(dbname, username):
curs = conn.cursor()
curs.execute(
"""
REVOKE ALL PRIVILEGES ON %(dbname)s.* FROM %(username)s@'%%'
""",
{'dbname': dbname, 'username': username})
REVOKE ALL PRIVILEGES ON `%(dbname)s`.* FROM %%(username)s@'%%%%'
""" % {'dbname': dbname}, {'username': username})
conn.commit()
return True