Airflow database querying - flask

I am having a flask application which uses airflow data.I would like to access the airflow database from my flask application and query the data.I am able to run raw SQL query.But i should have a solution how to use SQL alchemy query technique in it. For example if i need the dag table data. I should be able to run Dag.query.all() to get all dag data.

Airflow uses SQLAlchemy (currently 1.1.x for the Airflow 1.10 trunk) to manage its models, so you can interact with and query them using the standard SQLAlchemy API as documented in the tutorial.
https://docs.sqlalchemy.org/en/rel_1_1/orm/tutorial.html
You can access your database using a standard database connection string from any Python code, such as your Flask app, as described in the above tutorial as well.
There are examples of various the database connection URL formats supported by create_engine() here.
https://docs.sqlalchemy.org/en/rel_1_1/core/engines.html#database-urls
You can find more info such as the fields on a particular model in Airflow's models.py file.
https://github.com/apache/incubator-airflow/blob/master/airflow/models.py
You can find more SQLAlchemy documentation here.
https://docs.sqlalchemy.org/en/rel_1_1/

Related

Django admin command equivalent for gin golang

I want to write a script a to migrate data from one table to another using gin golang. The dataset is quite big so I can't create an API endpoint and do it as it will get timed out. I am looking an equivalent of django admin commands for golang that can help me to connect to the database easily and perform these task.

How to use Django ORM with cloud NDB?

I am trying to create an django project in which database is handled by cloud NDB. I checked out the cloud ndb documentation here and it only specifies the middleware that I need to include in my settings.py file. I want to use django ORM facility but I don't know how to do that with cloud NDB. I don't even know if I can use it so any answers are welcome.
Thank you for help.

Can I use Cassandra as Apache Airflow backend DB

I was going through the Airflow documentation and as per the documentation
As Airflow was built to interact with its metadata using the great SqlAlchemy library, you should be able to use any database backend supported as a SqlAlchemy backend.
Although Cassandra doesn't support SqlAlchemy, I see the project Flask-CQLAlchemy provides and SQLAlchemy like API.
Flask-CQLAlchemy handles connections to Cassandra clusters and provides a Flask-SQLAlchemy like interface to declare models and their columns in a Flask app Links
I am just getting started with Airflow and trying to setup its backend Db, will Cassandra with Flas-CQLAlchemy works for Airlow metadata repo?

Google App data store and GQL in Django

Is there a way to use GQL and Google App engine data store with Django? If yes then how to use it, I have searched on web but I am unable to find any satisfying answers to this problem?
In case of both cloud-sql and django-nonrel we dont use GQL as query language. They use SQL and MySql. But I wanted to use GQL in Django. So when I looked at documentation of Google app data store and GQL for google app engine webapp2 I found out that it has nothing to do with webapp2, instead it was for python. So only thing which I changed to make it working for Django was the method of rendering the request.

Integrate django application with turbogears

I am working with a legacy web application based off of Turbogears 1.1 (CherryPy 2.3) and I would like to integrate it with a Django 1.4 web application. What I would like to do ideally is find some way for both applications to share authentication/session state so that the experience is seamless to the user.
Both applications can run on the same server and technically can access the same mysql database instance.
Initial thoughts are that this could be achieved by:
Storing session data in a shared database
Use the Django application as a 'master' that would issue requests via http to the turbogears application
Running the Django application from within Cherrpy via the internal CherryPyWSGIServer
Any other suggestions would be welcome!
I would suggest looking into creating a custom Django auth and session backend which reuses the existing Turbogears data. You will likely also find it necessary to use Django 1.5's configurable user model.