Esempio n. 1
0
 def test_sqlite_operator_with_multiple_statements(self):
     sql = [
         "CREATE TABLE IF NOT EXISTS test_airflow (dummy VARCHAR(50))",
         "INSERT INTO test_airflow VALUES ('X')",
     ]
     op = SqliteOperator(task_id='sqlite_operator_with_multiple_statements', sql=sql, dag=self.dag)
     op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
Esempio n. 2
0
 def test_sqlite_operator_with_one_statement(self):
     sql = """
     CREATE TABLE IF NOT EXISTS test_airflow (
         dummy VARCHAR(50)
     );
     """
     op = SqliteOperator(task_id='basic_sqlite', sql=sql, dag=self.dag)
     op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
Esempio n. 3
0
    def test_sqlite_operator_with_invalid_sql(self):
        sql = [
            "CREATE TABLE IF NOT EXISTS test_airflow (dummy VARCHAR(50))",
            "INSERT INTO test_airflow2 VALUES ('X')",
        ]

        from sqlite3 import OperationalError
        try:
            op = SqliteOperator(
                task_id='sqlite_operator_with_multiple_statements', sql=sql, dag=self.dag)
            op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
            pytest.fail("An exception should have been thrown")
        except OperationalError as e:
            assert 'no such table: test_airflow2' in str(e)