1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Airflow1.9でユーザが作れないときに一時的な対処法

Last updated at Posted at 2018-03-07

公式では以下の手順で作成するように書かれている

公式
import airflow
from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
user = PasswordUser(models.User())
user.username = 'new_user_name'
user.email = 'new_user_email@example.com'
user.password = 'set_the_password'
session = settings.Session()
session.add(user)
session.commit()
session.close()
exit()

しかしuser.password = ...のところでAttributeError: can't set attributeとエラーが出る
パスワード設定時、以下のようにすれば一応作成できる

from flask_bcrypt import generate_password_hash
user._password = generate_password_hash(password, 12)

ソースを見るとpython3系を使っている場合はstrでキャストしてあげる必要があるっぽいので注意

参考

ソース

更新

タイトルにバージョン追加

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?