DAG をトリガーします。たとえば、手動でトリガーすることも、スケジュールに従い実行されるまで待つこともできます。
DAG の例:
importdatetimeimportosimportairflowfromairflow.providers.postgres.operators.postgresimportPostgresOperatorSQL_DATABASE=os.environ["SQL_DATABASE"]withairflow.DAG("airflow_db_connection_example",start_date=datetime.datetime(2024,1,1),schedule_interval=None,catchup=False)asdag:PostgresOperator(task_id="run_airflow_db_query",dag=dag,postgres_conn_id="airflow_db",database=SQL_DATABASE,sql="SELECT * FROM dag LIMIT 10;",)
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-02-19 UTC。"],[[["This page explains how to connect to and run SQL queries on the Cloud SQL instance that hosts the Airflow database for your Cloud Composer environment."],["While direct access to the Airflow database is possible, it's advised to use alternative methods like the Airflow REST API or CLI commands whenever feasible."],["To connect, create a DAG with `PostgresOperator` operators, specifying the SQL query in the `sql` parameter, and uploading/triggering it."],["It is not recommended to add custom tables or change the schema of the airflow database."],["Backing up the environment's data, including the Airflow database, should be done using snapshots instead of the deprecated database dumping method."]]],[]]