You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/12/20 07:23:52 UTC

[GitHub] [airflow] dstandish opened a new pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

dstandish opened a new pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863
 
 
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [ ] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR"
     - https://issues.apache.org/jira/browse/AIRFLOW-XXX
     - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue.
     - In case you are proposing a fundamental code change, you need to create an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)).
     - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Description
   
   - [ ] Here are some details about my PR, including screenshots of any UI changes:
   
   ### Tests
   
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   ### Commits
   
   - [ ] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [ ] In case of new functionality, my PR adds documentation that describes how to use it.
     - All the public functions and the classes in the PR contain docstrings that explain what it does
     - If you implement backwards incompatible changes, please leave a note in the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so we can assign it to a appropriate release
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] kaxil commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360819453
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -61,29 +59,167 @@ to the connection you wish to edit in the connection list.
 Modify the connection properties and click the ``Save`` button to save your
 changes.
 
-Creating a Connection with Environment Variables
+Storing a Connection in Environment Variables
 ------------------------------------------------
 
-Connections in Airflow pipelines can be created using environment variables.
-The environment variable needs to have a prefix of ``AIRFLOW_CONN_`` for
-Airflow with the value in a URI format to use the connection properly.
+The environment variable naming convention is ``AIRFLOW_CONN_<conn_id>``, all uppercase.
+
+So if your connection id is ``my_prod_db`` then the variable name should be ``AIRFLOW_CONN_MY_PROD_DB``.
+
+.. note::
+
+    There is only one underscore surrounding ``CONN``.  This is in contrast with the way ``airflow.cfg``
+    parameters are stored, where two underscores surround the config section name.
+
+The value of this environment variable must use airflow's URI format for connections.  See the section
+:ref:`Generating a Connection URI <generating_connection_uri>` for more details.
+
+Using .bashrc (or similar)
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If storing the environment variable in something like ``~/.bashrc``, you would add it ike so:
+
+.. code-block:: bash
+
+    export AIRFLOW_CONN_MY_PROD_DATABASE='my-conn-type://login:password@host:port/schema?param1=val1&param2=val2'
+
+Using docker .env
+^^^^^^^^^^^^^^^^^
+
+If using with a docker ``.env`` file, you may need to remove the single quotes.
+
+.. code-block::
+
+    AIRFLOW_CONN_MY_PROD_DATABASE=my-conn-type://login:password@host:port/schema?param1=val1&param2=val2
+
+
+Creating a Connection from the CLI
+----------------------------------
+
+You may add a connection to the database from the CLI.
+
+Obtain the URI for your connection (see :ref:`Generating a Connection URI <generating_connection_uri>`).
+
+Then add connection like so:
+
+.. code-block:: bash
+
+    airflow connections add --conn_id 'my_prod_db' --conn_uri 'my-conn-type://login:password@host:port/schema?param1=val1&param2=val2'
+
+Alternatively you may specify each parameter individually:
+
+.. code-block:: bash
+
+    airflow connections add \
+        --conn_id 'my_prod_db' \
+        --login 'login' \
+        --password 'password' \
+        ...
+
+
+Connection URI format
+---------------------
+
+In general, Airflow's URI format is like so:
+
+.. code-block::
+
+    my-conn-type://my-login:my-password@my-host:5432/my-schema?param1=val1&param2=val2
 
-When referencing the connection in the Airflow pipeline, the ``conn_id``
-should be the name of the variable without the prefix. For example, if the
-``conn_id`` is named ``postgres_master`` the environment variable should be
-named ``AIRFLOW_CONN_POSTGRES_MASTER`` (note that the environment variable
-must be all uppercase).
+.. note::
 
-Airflow assumes the value returned from the environment variable to be in a URI
-format (e.g. ``postgres://user:password@localhost:5432/master`` or
-``s3://accesskey:secretkey@S3``). The underscore character is not allowed
-in the scheme part of URI, so it must be changed to a hyphen character
-(e.g. ``google-compute-platform`` if ``conn_type`` is ``google_compute_platform``).
-Query parameters are parsed to one-dimensional dict and then used to fill extra.
+    The params param1 and param2 are just examples; you may supply arbitrary urlencoded json-serializable data there.
 
 Review comment:
   ```suggestion
       The params ``param1`` and ``param2`` are just examples; you may supply arbitrary urlencoded json-serializable data there.
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568302581
 
 
   @kaxil after taking another look i could not resist doing a little refactoring of connections section
   
   i will add to this existing pr in separate commit but if you think it's too much i can chop it and address later separately.  will be pushing in next few mins.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] kaxil commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360701746
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -81,6 +81,36 @@ in the scheme part of URI, so it must be changed to a hyphen character
 (e.g. ``google-compute-platform`` if ``conn_type`` is ``google_compute_platform``).
 Query parameters are parsed to one-dimensional dict and then used to fill extra.
 
+Generating a connection URI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Building the URI for a connection can be tricky.  To make it easier, the
+:py:class:`~airflow.models.connection.Connection` class has a convenience method
+:py:meth:`~airflow.models.connection.Connection.get_uri`.  It can be used like so:
+
+.. code-block:: python
+
+    from airflow.models.connection import Connection
+
+    c = Connection(
+        conn_id='some_conn',
+        conn_type='mysql',
+        host='myhost.com',
+        login='myname',
+        password='mypassword',
+        extra=json.dumps(dict(this_param='some val', that_param='other val*')),
+    )
+    print(f"AIRFLOW_CONN_{c.conn_id.upper()}='{c.get_uri()}'")
+
 
 Review comment:
   Can you add an example output of such URI

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish edited a comment on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish edited a comment on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568302581
 
 
   @kaxil after taking another look i could not resist doing a little refactoring of connections section
   
   i will add to this existing PR in separate commit but if you think it's too much i can chop it and address later separately.  will be pushing in next few mins.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish edited a comment on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish edited a comment on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568305989
 
 
   OK @mik-laj i have switched to `pycon` where appropriate.  at first i thought you were pointing out a typo :)
   
   And @kaxil  the refactor commit has been pushed.
   
   This second commit makes the following enhancements:
   * simplify description of naming convention for environment variables
   * add small notes how `.bashrc` and docker `.env` are different
   * add section on using the CLI (previously there was no mention of using the CLI)
   * make URI discussion separate from environment variables (because URI can also be used in CLI)
   * explain how to debug URI parsing, and handle special characters (though i note you can use `get_uri` and not worry about the details)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360730401
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -81,6 +81,38 @@ in the scheme part of URI, so it must be changed to a hyphen character
 (e.g. ``google-compute-platform`` if ``conn_type`` is ``google_compute_platform``).
 Query parameters are parsed to one-dimensional dict and then used to fill extra.
 
+Generating a connection URI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Building the URI for a connection can be tricky.  To make it easier, the
+:py:class:`~airflow.models.connection.Connection` class has a convenience method
+:py:meth:`~airflow.models.connection.Connection.get_uri`.  It can be used like so:
+
+.. code-block:: python
 
 Review comment:
   cool! thank you will do this

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] mik-laj commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360730383
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -61,29 +61,162 @@ to the connection you wish to edit in the connection list.
 Modify the connection properties and click the ``Save`` button to save your
 changes.
 
-Creating a Connection with Environment Variables
+Storing a Connection in Environment Variables
 ------------------------------------------------
 
-Connections in Airflow pipelines can be created using environment variables.
-The environment variable needs to have a prefix of ``AIRFLOW_CONN_`` for
-Airflow with the value in a URI format to use the connection properly.
+The environment variable naming convention is ``AIRFLOW_CONN_<conn_id>``, all uppercase.
 
-When referencing the connection in the Airflow pipeline, the ``conn_id``
-should be the name of the variable without the prefix. For example, if the
-``conn_id`` is named ``postgres_master`` the environment variable should be
-named ``AIRFLOW_CONN_POSTGRES_MASTER`` (note that the environment variable
-must be all uppercase).
+So if your connection id is ``my_prod_db`` then the variable name should be ``AIRFLOW_CONN_MY_PROD_DB``.
 
-Airflow assumes the value returned from the environment variable to be in a URI
-format (e.g. ``postgres://user:password@localhost:5432/master`` or
-``s3://accesskey:secretkey@S3``). The underscore character is not allowed
-in the scheme part of URI, so it must be changed to a hyphen character
-(e.g. ``google-compute-platform`` if ``conn_type`` is ``google_compute_platform``).
-Query parameters are parsed to one-dimensional dict and then used to fill extra.
+.. note::
+
+    There is only one underscore surrounding ``CONN``.  This is in contrast with the way ``airflow.cfg``
+    parameters are stored, where two underscores surround the config section name.
+
+The value of this environment variable must use airflow's URI format for connections.  See the section
+:ref:`Generating a Connection URI <generating_connection_uri>` for more details.
+
+Notes
+^^^^^
+
+If storing the environment variable in something like ``~/.bashrc``, you would add it ike so:
+
+.. code-block:: bash
+
+    export AIRFLOW_CONN_MY_PROD_DATABASE='my-conn-type://login:password@host:port/schema?param1=val1&param2=val2'
+
+If using with a docker ``.env`` file, you may need to remove the single quotes.
+
+.. code-block::
+
+    AIRFLOW_CONN_MY_PROD_DATABASE=my-conn-type://login:password@host:port/schema?param1=val1&param2=val2
+
+
+Creating a Connection from the CLI
+----------------------------------
+
+You may add a connection to the database from the CLI.
+
+Obtain the URI for your connection (see :ref:`Generating a Connection URI <generating_connection_uri>`).
+
+Then add connection like so:
+
+.. code-block:: bash
+
+    airflow connections add --conn_id 'my_prod_db' --conn_uri 'my-conn-type://login:password@host:port/schema?param1=val1&param2=val2'
+
+Alternatively you may specify each parameter individually:
+
+.. code-block:: bash
+
+    airflow connections add \
+        --conn_id 'my_prod_db' \
+        --login 'login' \
+        --password 'password' \
+        ...
+
+
+Connection URI format
+---------------------
+
+In general, Airflow's URI format is like so:
+
+.. code-block::
+
+    my-conn-type://my-login:my-password@my-host:5432/my-schema?param1=val1&param2=val2
+
+.. note::
+
+    The params param1 and param2 are just examples; you may supply arbitrary urlencoded json-serializable data there.
+
+The above URI would produce a ``Connection`` object equivalent to the following:
+
+.. code-block:: python
+
+    Connection(
+        conn_id='',
+        conn_type='my_conn_type',
+        login='my-login',
+        password='my-password',
+        host='my-host',
+        port=5432,
+        schema='my-schema',
+        extra=json.dumps(dict(param1='val1', param2='val2'))
+    )
+
+You can verify a URI is parsed correctly like so:
+
+.. code-block:: python
 
 Review comment:
   ```suggestion
   .. code-block:: pycon
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] mik-laj commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360730191
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -81,6 +81,38 @@ in the scheme part of URI, so it must be changed to a hyphen character
 (e.g. ``google-compute-platform`` if ``conn_type`` is ``google_compute_platform``).
 Query parameters are parsed to one-dimensional dict and then used to fill extra.
 
+Generating a connection URI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Building the URI for a connection can be tricky.  To make it easier, the
+:py:class:`~airflow.models.connection.Connection` class has a convenience method
+:py:meth:`~airflow.models.connection.Connection.get_uri`.  It can be used like so:
+
+.. code-block:: python
 
 Review comment:
   ```suggestion
   .. code-block:: pycon
   ```
   Reference: https://pygments.org/docs/lexers/#pygments.lexers.python.PythonConsoleLexer

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] kaxil commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568469290
 
 
   Good addition, thanks @dstandish 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] kaxil merged pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568427659
 
 
   updated; thanks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish edited a comment on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish edited a comment on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568302581
 
 
   @kaxil after taking another look i could not resist doing a little refactoring of connections section
   
   i will add to this existing PR, but in separate commit
   
   if you think it's too much i can chop it and address later separately.  will be pushing in next few mins.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] kaxil commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360819202
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -61,29 +59,167 @@ to the connection you wish to edit in the connection list.
 Modify the connection properties and click the ``Save`` button to save your
 changes.
 
-Creating a Connection with Environment Variables
+Storing a Connection in Environment Variables
 ------------------------------------------------
 
-Connections in Airflow pipelines can be created using environment variables.
-The environment variable needs to have a prefix of ``AIRFLOW_CONN_`` for
-Airflow with the value in a URI format to use the connection properly.
+The environment variable naming convention is ``AIRFLOW_CONN_<conn_id>``, all uppercase.
+
+So if your connection id is ``my_prod_db`` then the variable name should be ``AIRFLOW_CONN_MY_PROD_DB``.
+
+.. note::
+
+    There is only one underscore surrounding ``CONN``.  This is in contrast with the way ``airflow.cfg``
+    parameters are stored, where two underscores surround the config section name.
+
+The value of this environment variable must use airflow's URI format for connections.  See the section
+:ref:`Generating a Connection URI <generating_connection_uri>` for more details.
+
+Using .bashrc (or similar)
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If storing the environment variable in something like ``~/.bashrc``, you would add it ike so:
 
 Review comment:
   ```suggestion
   If storing the environment variable in something like ``~/.bashrc``, add it as follow:
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish commented on a change in pull request #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#discussion_r360723696
 
 

 ##########
 File path: docs/howto/connection/index.rst
 ##########
 @@ -81,6 +81,36 @@ in the scheme part of URI, so it must be changed to a hyphen character
 (e.g. ``google-compute-platform`` if ``conn_type`` is ``google_compute_platform``).
 Query parameters are parsed to one-dimensional dict and then used to fill extra.
 
+Generating a connection URI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Building the URI for a connection can be tricky.  To make it easier, the
+:py:class:`~airflow.models.connection.Connection` class has a convenience method
+:py:meth:`~airflow.models.connection.Connection.get_uri`.  It can be used like so:
+
+.. code-block:: python
+
+    from airflow.models.connection import Connection
+
+    c = Connection(
+        conn_id='some_conn',
+        conn_type='mysql',
+        host='myhost.com',
+        login='myname',
+        password='mypassword',
+        extra=json.dumps(dict(this_param='some val', that_param='other val*')),
+    )
+    print(f"AIRFLOW_CONN_{c.conn_id.upper()}='{c.get_uri()}'")
+
 
 Review comment:
   good idea
   i have amended
   thanks for the review

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] dstandish commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`

Posted by GitBox <gi...@apache.org>.
dstandish commented on issue #6863: [AIRFLOW-XXX] add docs showing usage of `Connection.get_uri`
URL: https://github.com/apache/airflow/pull/6863#issuecomment-568305989
 
 
   OK i have switched to `pycon` where appropriate.  at first i thought you were pointing out a typo :)
   
   The second commit makes the following enhancements:
   * simplify description of naming convention for environment variables
   * add small notes how `.bashrc` and docker `.env` are different
   * add section on using the CLI (previously there was no mention of using the CLI)
   * make URI discussion separate from environment variables (because URI can also be used in CLI)
   * explain how to debug URI parsing, and handle special characters (though i note you can use `get_uri` and not worry about the details)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services