Replies: 1 comment
-
Ended up using this single plugin file approach: from airflow.plugins_manager import AirflowPlugin
from airflow.utils.db import provide_session
from airflow.models.base import Base
from sqlalchemy import inspect
from sqlalchemy import Column, Integer, String
class Custom(Base):
__tablename__ = 'custom'
id = Column(Integer, primary_key=True)
name = Column(String(255), nullable=False)
description = Column(String(255))
@provide_session
def create_custom_table(session=None):
engine = session.get_bind()
Custom.__table__.create(engine, checkfirst=True)
# Define the plugin
class CustomPlugin(AirflowPlugin):
name = 'custom_plugin'
def on_load(self, *args, **kwargs):
create_custom_table() But not sure if this is the best way to do this... Any help would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings. In Airflow Plugins, what is the proper way to define a custom model for storing plugin specific data in airflow's postgres metadata database?
I've tried the approach in this post: Airflow Plugin - create own model and use airflow metadatabase for storing plugin specific data
But it doesn't seem to work.
Beta Was this translation helpful? Give feedback.
All reactions