Hello Nicholas,

yes there is:

for variables you can do:

from airflow.models import Variable
Variable.set(key, value)

for connections you can do:

from airflow import settings
from airflow.models import Connection

def create_connection(
     conn_id, conn_type, host, schema, login, password, port=None,
extra=None):
    logging.info('Creating connection %s' % conn_id)
    new_conn = Connection()
    new_conn.conn_id = conn_id
    new_conn.conn_type = conn_type
    new_conn.host = host
    new_conn.schema = schema
    new_conn.login = login
    new_conn.password = password
    if port:
        new_conn.port = port
    if extra:
        new_conn.extra = extra
    session = settings.Session()
    session.add(new_conn)
    session.commit()
    session.close()


You can extend and modify these to fit your needs as necessary.

On Tue, Mar 7, 2017 at 11:49 PM, Nicholas Hodgkinson <
[email protected]> wrote:

> I would like to be able to create a script to assist local development
> which would populate several Connections and Variables that are used across
> our organization; is there a way that I can add those from the command line
> or Python script without having to manually enter them via the UI?
>
> Thanks,
> -Nik
> [email protected]
>
> --
>
>
> Read our founder's story.
> <https://collectivehealth.com/blog/started-collective-health/>
>
> *This message may contain confidential, proprietary, or protected
> information.  If you are not the intended recipient, you may not review,
> copy, or distribute this message. If you received this message in error,
> please notify the sender by reply email and delete this message.*
>

Reply via email to