def check_tables(schema, provider, connection): cursor = connection.cursor() split = provider.split_table_name for table in sorted(itervalues(schema.tables), key=lambda table: split(table.name)): alias = provider.base_name(table.name) sql_ast = [ 'SELECT', [ 'ALL', ] + [ [ 'COLUMN', alias, column.name ] for column in table.column_list ], [ 'FROM', [ alias, 'TABLE', table.name ] ], [ 'WHERE', [ 'EQ', [ 'VALUE', 0 ], [ 'VALUE', 1 ] ] ] ] sql, adapter = provider.ast2sql(sql_ast) if core.local.debug: log_sql(sql) provider.execute(cursor, sql)
def check_tables(schema, provider, connection): cursor = connection.cursor() for table in sorted(itervalues(schema.tables), key=lambda table: table.name): if isinstance(table.name, tuple): alias = table.name[-1] elif isinstance(table.name, basestring): alias = table.name else: assert False # pragma: no cover sql_ast = [ 'SELECT', [ 'ALL', ] + [ [ 'COLUMN', alias, column.name ] for column in table.column_list ], [ 'FROM', [ alias, 'TABLE', table.name ] ], [ 'WHERE', [ 'EQ', [ 'VALUE', 0 ], [ 'VALUE', 1 ] ] ] ] sql, adapter = provider.ast2sql(sql_ast) if core.debug: log_sql(sql) provider.execute(cursor, sql)
def create(table, provider, connection, created_tables=None): commands = table.get_create_commands(created_tables) for i, sql in enumerate(commands): if core.debug: log_sql(sql) cursor = connection.cursor() try: provider.execute(cursor, sql) except DatabaseError, e: if e.exceptions[0].args[0].code == 955: if core.debug: log_orm('ALREADY EXISTS: %s' % e.args[0].message) if not i: if len(commands) > 1: log_orm('SKIP FURTHER DDL COMMANDS FOR TABLE %s\n' % table.name) return else: raise
def create(table, provider, connection): sql = table.get_create_command() if core.local.debug: log_sql(sql) cursor = connection.cursor() provider.execute(cursor, sql)
def create(table, provider, connection): sql = table.get_create_command() if core.debug: log_sql(sql) cursor = connection.cursor() provider.execute(cursor, sql)
def create(table, provider, connection, created_tables=None): commands = table.get_create_commands(created_tables) for sql in commands: if core.debug: log_sql(sql) cursor = connection.cursor() provider.execute(cursor, sql)
async def _create(self, provider, connection): sql = self.get_create_command() if core.debug: log_sql(sql) cursor = await connection.cursor() await provider.execute(cursor, sql)