Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

CONNECTs other than LIB CONNECT are not available in this script mode

Hi,

I am trying to dynamically load ODBC Connection string through xml file (custom config file ) in  Qlik Sense Desktop 1.1  as below:

LET vFolderPath = 'lib://ReportsFilePath/';

LOAD key, value
FROM $(vFolderPath)AppConfig.xml (XmlSimple, Table is [qsConfiguration/qsElement])
WHERE key = 'ConnString';

LET vConnString = peek('value');

ODBC Connect to $(vConnString);

However, I receive following error on last line as:

CONNECTs other than LIB CONNECT are not available in this script mode.

Can you please help?

Thanks,

Greeshma

7 Replies
Gysbert_Wassenaar

You have to define your ODBC connections first. Click on the Add Connection button in the Data Load Editor and choose ODBC from the standard connectors. Fill in the Create new connection (ODBC) form and save it. Then you can use this kind of connect statement:

LIB CONNECT TO 'AdventureWorksDW2014_ODBC';


talk is cheap, supply exceeds demand
Not applicable
Author

I instead wish to load connection string from a config file. In my example above,

vConnString= " Provider=****;User Id=****; Password=****;Persist Security Info=****;Data Source=**** "

I am able to successfully connect using ODBC Connections defined under Data Connections. However, my intention is to load connection strings dynamically so that it could be run for different environment without any modifications to the data model script.

Gysbert_Wassenaar

I think you'll have to create connections for each environment and choose the one you need. Maybe something like:

LET vEnv = 'Test'; //Choose from Dev, Test, Uat, Prod


LIB CONNECT 'MyODBC_DB_$(vEnv)' ;


talk is cheap, supply exceeds demand
Not applicable
Author

Yup. That's one solution. That's how I am doing it now.  However, that hides connection information at run time.

Is there any specific file I can look at to see how connection is defined within Data Connections? Please let me know.

Thanks.

Gysbert_Wassenaar

You could also use the same variable to load a file with connection information into another variable (or a table) for display in the front end.

My guess is that the data connection definitions will be stored in the qvf file.


talk is cheap, supply exceeds demand
JonnyPoole
Employee
Employee

Couple things:

You can actually run the load editor in legacy mode which will forego using the data connections that you define. In legacy mode the entire script runs as it would in QlikView. I'm not sure i recommend this but its possible.

When you import the QVF app into Qlik Sense server, unless there are connections of the same name already on the server, the server will add them into the QMC.  You can edit the connection from the QMC and see the full connect string.  I don't believe you can use variables here however. I tried some testing (set a variable in the load editor) and reference the variable in the connect string of the data connection used in the load script... but was not successful.

ikomlyakov1929
Partner - Contributor III
Partner - Contributor III

But you can make your Server to load data in legacy mode too but you won't be able to manage the connection strings in QMC anymore.