예제 #1
0
 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),
     )
예제 #2
0
    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)
예제 #3
0
    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)