Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3 raised an error after running Airflow command line

Tags:

sqlite

airflow

When I ran command: airflow list_users It raised an error as below:

sqlite3.OperationalError: no such table: ab_permission_view_role

...

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: 
ab_permission_view_role [SQL: 'SELECT ab_permission_view_role.id AS 
ab_permission_view_role_id, ab_permission_view_role.permission_view_id AS ab_permission_view_role_permission_view_id, ab_permission_view_role.role_id AS 
ab_permission_view_role_role_id \nFROM ab_permission_view_role JOIN 
ab_permission_view ON ab_permission_view.id = 
ab_permission_view_role.permission_view_id JOIN ab_view_menu ON ab_view_menu.id = ab_permission_view.view_menu_id \nWHERE ab_permission_view_role.role_id = ? 
AND ab_permission_view.view_menu_id != ?'] [parameters: (4, 51)] (Background on 
this error at: http://sqlalche.me/e/e3q8)

There is also the same error after running: airflow create_user

like image 777
DennisLi Avatar asked Jul 17 '19 04:07

DennisLi


Video Answer


3 Answers

[Airflow v1] This happened because ab_* tables were not created at airflow initdb. All these tables are for Role-based-access-control – RBAC.

To have these tables, follow the instructions:

edit airflow.cfg

[webserver]
rbac = True

and run airflow initdb to create these missed tables.

like image 192
Newton José Avatar answered Oct 19 '22 19:10

Newton José


In addition to the answer by Newton Jose, after editing the cfg file, start the webserver using

airflow webserver

Then open another terminal, switch to your working directory and run

airflow initdb

You can now start your scheduler

airflow scheduler

The bottomline is that your webserver should be running when you run the command for initializing the database. Atleast, that is what worked for me.

like image 34
Xceptions Avatar answered Oct 19 '22 21:10

Xceptions


You need to perform initialization after installation:

$ export AIRFLOW_HOME=~/airflow
$ airflow initdb

If AIRFLOW_HOME is unset, ~/airflow/ will be created and used. This is where the config and logs will be stored; if you want to reset the configuration, remove the dir stored in AIRFLOW_HOME and rerun airflow initdb.

Now other commands should work, e.g.

$ airflow version
[2019-08-15 22:39:34,673] {__init__.py:51} INFO - Using executor SequentialExecutor
  ____________       _____________
 ____    |__( )_________  __/__  /________      __
____  /| |_  /__  ___/_  /_ __  /_  __ \_ | /| / /
___  ___ |  / _  /   _  __/ _  / / /_/ /_ |/ |/ /
 _/_/  |_/_/  /_/    /_/    /_/  \____/____/|__/  v1.10.4

Source: Installation section from airflow docs.

like image 2
Abhishek Shingadiya Avatar answered Oct 19 '22 20:10

Abhishek Shingadiya