[英]How to get the Table Name after establishment a database connection using appache airflow
我正在使用 appache airflow 進行數據庫連接。
我正在使用以下代碼
>>> import json
>>> from airflow.models.connection import Connection
>>> c = Connection(
>>> conn_id='some_conn',
>>> conn_type='mysql',
>>> description='connection description',
>>> host='myhost.com',
>>> login='myname',
>>> password='mypassword',
>>> extra=json.dumps(dict(this_param='some val', that_param='other val*')),
>>> )
>>> print(f"AIRFLOW_CONN_{c.conn_id.upper()}='{c.get_uri()}'")
AIRFLOW_CONN_SOME_CONN='mysql://myname:mypassword@myhost.com?this_param=some+val&that_param=other+val%2A'
現在數據建立完成了。 但是我如何獲得與那個 perticulat 數據庫關聯的表
您可以使用MySqlOperator
和這樣的查詢來獲取數據庫中的表:
SELECT table_name FROM information_schema.tables
WHERE table_schema = 'your_database_name';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.