Ejemplo n.º 1
0
    def test_table_drop_on_cluster(self):
        drop_sql = 'DROP TABLE IF EXISTS t1 ON CLUSTER test_cluster'

        with mocked_engine() as engine:
            table = Table('t1',
                          self.metadata(session=engine.session),
                          Column('x', types.Int32, primary_key=True),
                          clickhouse_cluster='test_cluster')
            table.drop(if_exists=True)
            self.assertEqual(engine.history, [drop_sql])

        self.assertEqual(self.compile(DropTable(table, if_exists=True)),
                         drop_sql)
Ejemplo n.º 2
0
    def test_table_create_on_cluster(self):
        table = Table('t1',
                      self.metadata(),
                      Column('x', types.Int32, primary_key=True),
                      engines.Memory(),
                      clickhouse_cluster='test_cluster')
        create_sql = ('CREATE TABLE t1 ON CLUSTER test_cluster '
                      '(x Int32) ENGINE = Memory')

        with mocked_engine() as engine:
            table.create()
            engine.assert_sql([create_sql])

        self.assertEqual(self.compile(CreateTable(table)), create_sql)
Ejemplo n.º 3
0
 def test_table_drop(self):
     with mocked_engine() as engine:
         table = Table('t1', self.metadata(session=engine.session),
                       Column('x', types.Int32, primary_key=True))
         table.drop(if_exists=True)
         self.assertEqual(engine.history, ['DROP TABLE IF EXISTS t1'])