def make_table(table_def, conn_params):
    table = Table(table_def["name"])
    cols = [Column(k, v) for k, v, in table_def["columns"].items()]

    drop = Query.drop_table(table).if_exists()
    create = Query.create_table(table).columns(*cols)

    execute_query(str(drop) + "\n" + str(create), conn_params)
Пример #2
0
    def test_drop_table_if_exists(self):
        q = Query.drop_table(self.new_table).if_exists()

        self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q))
Пример #3
0
    def test_drop_table(self):
        q = Query.drop_table(self.new_table)

        self.assertEqual('DROP TABLE "abc"', str(q))
Пример #4
0
    def test_drop_table(self):
        q1 = Query.drop_table(self.new_table)
        q2 = Query.drop_table(self.new_table).if_exists()

        self.assertEqual('DROP TABLE "abc"', str(q1))
        self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2))