You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Luke Grzela (JIRA)" <ji...@apache.org> on 2017/07/19 10:00:00 UTC

[jira] [Created] (AIRFLOW-1429) Unable to add connections programatically if user/pass in the URI contain special characters

Luke Grzela created AIRFLOW-1429:
------------------------------------

             Summary: Unable to add connections programatically if user/pass in the URI contain special characters
                 Key: AIRFLOW-1429
                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1429
             Project: Apache Airflow
          Issue Type: Improvement
          Components: core
    Affects Versions: Airflow 1.7.1.3
         Environment: Ubuntu 14.04
            Reporter: Luke Grzela


Hello,

I hit a problem with adding FTP connections to airflow programmatically.
If there is a question mark in the username or password part of the FTP uri, i.e. if the URI is something like ftp://joe:my?pass@someftp.com, then everything before the questionmark will be treated as the URI and the rest I suppose is considered to be the query string, I tried replacing the ? with %3F, but it didn't help.

Here's our code for adding the connection:

{noformat}
from airflow import settings
from airflow.models import Connection

def add_connection(conn_id, uri): 
""" 
Add a connection to airflow's list of known connections.    
This function is internal, you can call it if you want,    
but best to use one of the above 'public' functions. 
"""    

conn = Connection(conn_id=conn_id, uri=uri)    
session = settings.Session()    
existing_conn = session.query(Connection).filter(Connection.conn_id == conn_id).first()    
if existing_conn:        
  session.delete(existing_conn)    
  session.add(conn)    
  session.commit()    
  session.close()
{noformat}

Is there any way to escape the question marks and any other special characters?

Thanks,
Luke




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)