def create_index(self, columns, table_name, if_not_exists = True, unique = False, **kwargs): 'Create a unique index on the column(s) passed.' index_name = simplify(table_name) + u'_' + u'_'.join(map(simplify, columns)) if unique: sql = u'CREATE UNIQUE INDEX %s ON %s (%s)' else: sql = u'CREATE INDEX %s ON %s (%s)' first_param = u'IF NOT EXISTS ' + index_name if if_not_exists else index_name params = (first_param, quote(table_name), ','.join(map(quote, columns))) self.execute(sql % params, **kwargs)