I\'m writing a little python script to help me automate the creation of mysql databases and associated accounts for my personal projects. Part of this script is a function t
A database name (nor column or table names) are not data values, and thus are not an appropriate use of placeholders. wanting to do this is usually a bad sign; only the DBA should be able to issue a create database, since doing so requires some considerable privileges. Most applications require the DBA to issue the create database, and then take the created database as a parameter to be used in the arguments to dbapi.Connection.
If you are sure you need this, you trust the source of the input, and you have checked the input for invalid characters, you would just do the substitution in python, something like:
def createDB(dbConn, dbName):
c = dbConn.cursor()
query = """CREATE DATABASE %s;""" % dbName
c.execute(query)