Skip to content

Instantly share code, notes, and snippets.

@kouk
Created April 5, 2021 15:52
Show Gist options
  • Save kouk/998195bd59a50e32b688ce4421336c41 to your computer and use it in GitHub Desktop.
Save kouk/998195bd59a50e32b688ce4421336c41 to your computer and use it in GitHub Desktop.
import airflow
import getpass
import logging
from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
def set_password(name, password):
session = settings.Session()
u = session.query(PasswordUser).filter_by(username=name).first()
u.password = password
session.add(u)
session.commit()
session.close()
if __name__ == "__main__":
logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
set_password("johndoe", getpass.getpass())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment