Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Connect Python to ODBC using Connection Alias

mayankbajaj123
5 - Atom

Hi All,

 

We had created this connection alias to connect to the database:

mayankbajaj123_2-1630072132823.png

 

 

 

This is working well with the normal input tool, but if I use this within a Python code (see below screenshot) , it gives us an error. Do you know if there is a way to use this alias within Python code?

 

mayankbajaj123_1-1630071948763.jpeg

 

1 REPLY 1
danilang
19 - Altair
19 - Altair

Hi @mayankbajaj123 

 

I don't know of any way to reference an Alteryx connection alias within a python tool.  The alias is used by the Alteryx engine to get the connection details.  Since the Python tool runs in a Jupyter Notebook environment, there's no way for the Jupyter environment to translate the alias into a connection string.  

 

You have a few options to deal with this.  

1.  Retrieve the data within Alteryx and pass the data to the Python tool.

2.  Define the connection string in Alteryx and pass it the python tool to pass as an argument to pyodbc.connect()

3.  Hard code the connection string in the python code.

 

Dan  

Labels