def test_create_table(self): q = MySQLQuery.create_table(self.table_abc).columns(Column( "id", "INT")) self.assertEqual( 'CREATE TABLE `abc` (`id` INT)', str(q), )
def create_temporary_table_from_select(self, table, select_query, connection=None): """ Creates a temporary table from a SELECT query. :param table: The name of the new temporary table. :param select_query: The query to be used for selecting data of an existing table for the new temporary table. :param connection: (Optional) The connection to execute this query with. """ create_query = MySQLQuery.create_table(table).temporary().as_select(select_query) self.execute(str(create_query), connection=connection)
def create_temporary_table_from_columns(self, table, columns, connection=None): """ Creates a temporary table from a list of columns. :param table: The name of the new temporary table. :param columns: The columns of the new temporary table. :param connection: (Optional) The connection to execute this query with. """ create_query = MySQLQuery.create_table(table).temporary().columns(*columns) self.execute(str(create_query), connection=connection)