ySQL: make _quoteIdentifier method public

This commit is contained in:
regilero 2013-12-01 11:04:06 +01:00
parent 772144af8a
commit b85d51f746

View File

@ -69,8 +69,8 @@ def __check_table(name, table, **connection_args):
if dbc is None: if dbc is None:
return {} return {}
cur = dbc.cursor(MySQLdb.cursors.DictCursor) cur = dbc.cursor(MySQLdb.cursors.DictCursor)
s_name = _quoteIdentifier(name) s_name = quoteIdentifier(name)
s_table = _quoteIdentifier(table) s_table = quoteIdentifier(table)
qry = 'CHECK TABLE %(dbname)s.%(dbtable)s' % dict(dbname=s_name, dbtable=s_table) qry = 'CHECK TABLE %(dbname)s.%(dbtable)s' % dict(dbname=s_name, dbtable=s_table)
log.debug('Doing query: {0}'.format(qry)) log.debug('Doing query: {0}'.format(qry))
cur.execute(qry) cur.execute(qry)
@ -84,8 +84,8 @@ def __repair_table(name, table, **connection_args):
if dbc is None: if dbc is None:
return {} return {}
cur = dbc.cursor(MySQLdb.cursors.DictCursor) cur = dbc.cursor(MySQLdb.cursors.DictCursor)
s_name = _quoteIdentifier(name) s_name = quoteIdentifier(name)
s_table = _quoteIdentifier(table) s_table = quoteIdentifier(table)
qry = 'REPAIR TABLE %(dbname)s.%(dbtable)s' % dict(dbname=s_name, dbtable=s_table) qry = 'REPAIR TABLE %(dbname)s.%(dbtable)s' % dict(dbname=s_name, dbtable=s_table)
log.debug('Doing query: {0}'.format(qry)) log.debug('Doing query: {0}'.format(qry))
cur.execute(qry) cur.execute(qry)
@ -99,8 +99,8 @@ def __optimize_table(name, table, **connection_args):
if dbc is None: if dbc is None:
return {} return {}
cur = dbc.cursor(MySQLdb.cursors.DictCursor) cur = dbc.cursor(MySQLdb.cursors.DictCursor)
s_name = _quoteIdentifier(name) s_name = quoteIdentifier(name)
s_table = _quoteIdentifier(table) s_table = quoteIdentifier(table)
qry = 'OPTIMIZE TABLE %(dbname)s.%(dbtable)s' % dict(dbname=s_name, dbtable=s_table) qry = 'OPTIMIZE TABLE %(dbname)s.%(dbtable)s' % dict(dbname=s_name, dbtable=s_table)
log.debug('Doing query: {0}'.format(qry)) log.debug('Doing query: {0}'.format(qry))
cur.execute(qry) cur.execute(qry)
@ -224,7 +224,7 @@ def _grant_to_tokens(grant):
database=database) database=database)
def _quoteIdentifier(identifier): def quoteIdentifier(identifier):
''' '''
Return an identifier name (column, table, database, etc) escaped accordingly for MySQL Return an identifier name (column, table, database, etc) escaped accordingly for MySQL
@ -549,7 +549,7 @@ def db_tables(name, **connection_args):
if dbc is None: if dbc is None:
return [] return []
cur = dbc.cursor() cur = dbc.cursor()
s_name = _quoteIdentifier(name) s_name = quoteIdentifier(name)
qry = 'SHOW TABLES IN %(dbname)s' % dict(dbname=s_name) qry = 'SHOW TABLES IN %(dbname)s' % dict(dbname=s_name)
log.debug('Doing query: {0}'.format(qry)) log.debug('Doing query: {0}'.format(qry))
try: try:
@ -628,7 +628,7 @@ def db_create(name, character_set=None, collate=None, **connection_args):
if dbc is None: if dbc is None:
return False return False
cur = dbc.cursor() cur = dbc.cursor()
s_name = _quoteIdentifier(name) s_name = quoteIdentifier(name)
qry = 'CREATE DATABASE %(dbname)s' % dict(dbname=s_name) qry = 'CREATE DATABASE %(dbname)s' % dict(dbname=s_name)
args = {} args = {}
if character_set is not None: if character_set is not None:
@ -675,7 +675,7 @@ def db_remove(name, **connection_args):
if dbc is None: if dbc is None:
return False return False
cur = dbc.cursor() cur = dbc.cursor()
s_name = _quoteIdentifier(name) s_name = quoteIdentifier(name)
qry = 'DROP DATABASE %(dbname)s;' % dict(dbname=s_name) qry = 'DROP DATABASE %(dbname)s;' % dict(dbname=s_name)
log.debug('Doing query: {0}'.format(qry)) log.debug('Doing query: {0}'.format(qry))
try: try: