Thursday 21 October 2021

airflow: Interacting with sqlite database

Airflow requires a database to be initialized before you can run tasks. If you’re just experimenting and learning Airflow, you can stick with the default SQLite option which comes by default.

 

In our previous examples, we are not configured any external database, so airflow starts with sqlite.

 

When you see the contents of ‘airflow’ folder, you can observe ‘airflow.db’ file gets created. Using sqlite, you can query this db file.  

$ls
airflow.cfg airflow.db  dags        logs        unittests.cfg

Query the contents of airflow.db file

Open terminal and execute below command to connect to airflow databse.

sqlite3 airflow.db

$sqlite3 airflow.db 
SQLite version 3.28.0 2019-04-15 14:49:49
Enter ".help" for usage hints.
sqlite> 


List all tables

Execute .tables command.

sqlite> .tables
alembic_version                kube_worker_uuid             
chart                          log                          
connection                     rendered_task_instance_fields
dag                            serialized_dag               
dag_code                       sla_miss                     
dag_pickle                     slot_pool                    
dag_run                        task_fail                    
dag_tag                        task_instance                
import_error                   task_reschedule              
job                            users                        
known_event                    variable                     
known_event_type               xcom                         
kube_resource_version       



 

Previous                                                    Next                                                    Home

No comments:

Post a Comment