Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

ODBC connection from Variable

Hi All,

We have one Redshift and another MySQL server Database.

I have created two separate DSNs for same.


We have a requirement, where just by changing the variable names, the user should be able to switch between MySQL and Redshift.

I have created three variables for DSN, UserName and Password and have the string in Edit Script section as :

ODBC CONNECT TO $(vDSN) (XUserId is $(vUser), XPassword is $(vPassword));


If I use below statement, the LOAD statement for aliasing does not work, but data gets loaded -

ODBC CONNECT TO $(vDSN) ;

Any inputs for same.

Even if I provide Username and Password, the LOAD statement is not working for MySQL.

Please let me know your inputs on same.

Thanks & Regards,

MK


5 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can use the If statement.

If variable = 1 then

     Connect to Mysql

Else

     Connect to RedShift

End if

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

Thanks Kaushik for the quick reply.

I can use that, but after that as well, If I am taking values of UserName, DSN and Password for MySQL from variable, LOAD statement asliasing does not work.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

It wont work because the username and password should be in encrypted format. Other wise it wont work and I dont think so its possible to know what encryption technique is used to encrypt the data.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
avinashelite

agrreed with  kaushik.solanki‌..you need to create the connection string inside the QV and its encrypted with the logic defined by Qlik so you cannot rebuild it using the variables ...try like creating to different connection strings and based on the condition you could connect for the required data base

Anonymous
Not applicable
Author

I have first connected the same using direct ODBC, connect box.

After that, I just copy paste the encrypted username and Password into variables.

LOAD statement works well for Redshift but not for MySQL.

If I just use ODBC connection for MySQL, without variables, then LOAD statement works as expected.

But in case of variables does not.