0
0
Apache Airflowdevops~10 mins

Database backend optimization in Apache Airflow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the database connection URI in Airflow configuration.

Apache Airflow
[core]
sql_alchemy_conn = [1]
Drag options to blanks, or click blank then click option'
Asqlite:///airflow.db
Bpostgresql+psycopg2://user:pass@localhost/airflow
Cmysql://user:pass@localhost/airflow
Doracle://user:pass@localhost/airflow
Attempts:
3 left
💡 Hint
Common Mistakes
Using SQLite URI for production environment.
Forgetting the driver name in the URI.
2fill in blank
medium

Complete the command to initialize the Airflow metadata database.

Apache Airflow
airflow db [1]
Drag options to blanks, or click blank then click option'
Ainit
Breset
Cmigrate
Dupgrade
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upgrade' which is for updating an existing database.
Using 'reset' which deletes data.
3fill in blank
hard

Fix the error in the SQLAlchemy connection string by choosing the correct driver name.

Apache Airflow
sql_alchemy_conn = postgresql+[1]://user:pass@localhost/airflow
Drag options to blanks, or click blank then click option'
Apsycopg2
Bcx_oracle
Cmysqlconnector
Dsqlite
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mysqlconnector' which is for MySQL.
Using 'sqlite' which is for SQLite databases.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters tasks with retries greater than 3.

Apache Airflow
filtered_tasks = {task_id: task for task_id, task in tasks.items() if task.[1] [2] 3}
Drag options to blanks, or click blank then click option'
Aretries
B>
C<
Dmax_retries
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max_retries' which is not a standard attribute.
Using '<' instead of '>' causing wrong filtering.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps task IDs to their owner names for tasks with priority above 5.

Apache Airflow
owners = { [1]: [2].owner for [3], [2] in dag.tasks.items() if [2].priority_weight > 5 }
Drag options to blanks, or click blank then click option'
Atask_id
Btask
Ctask_key
Dtask_obj
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for both key and value in the loop.
Using incorrect variable names causing syntax errors.