Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
kmswetha
Creator
Creator

Differenct connection strings

Hi,

I used include file for connection strings.

But my question is, I have different connection strings of different environments, how do I call them intelligently?

12 Replies
Not applicable

correct

place each include file in each environment - since they ahve the same name, there are no coding changes required this way when moving from one environment to another

Not applicable

Hi

The best way I have done is by having an Excel file with the connection strings in them. You will have to set up the ODBC connections or the the type of connection you are making.

In my data extraction script I  load the Excel file and loop through the connections to load the data. This is under the assumption that your data structure in each environment is the same as any changes or additional tables which do not exist in any other environments will throw an error.

To identify which table belongs to which environment, you can create a variable after declaring the while loop which will be the name of your environment. You can add this as a additional column in each of your tables in your structure. This will simply be the variable of the environment. This is will make it easy for identifying environment table.

Hope this helps.

lenka_kruse
Partner - Contributor III
Partner - Contributor III

Do you have one QV-extraction-application that needs to loop through all the connection-strings to load tables from different machines?

I usually do that by loading the machines/table-combinations from an excel-file and keeping the Connect-Strings in textfiles matching the machine-names, so that I only have to loop through the combinations:

 

MachineTableLoad
machine1table11
machine1table21
machine2table11
machine2table31

< Load the machines where Load = 1>

for i = 1 to FieldValueCount('Machine')

  let vS_Maschine = FieldValue('Machine',$(i));

  $(Include=$(vPath)\cs_$(vS_Maschine).qvs);

   <Load the tables where Machine = '$(vS_Maschine)' and Load = 1>

    for j = 1 to FieldValueCount('Table')

          let vS_Table = FieldValue('Table',$(j));

          load & store & drop $(vS_Table);

     next

     disconnect;

next

Make sure you disconnect at the end of each connect-loop, just to keep things clean!

I like this solution because a) it opens and closes every connection-string only once, which is good for the performance and b) it makes adding or deleting machines/tables really easy, because you only have to set Load to '1' or '0'.


Or do you have the same QV-application in different environments, so that it uses the same connection-string include-file, but with different paths?

I usually do that by checking via the document-path, whether the application is e.g. in the development or the production environment, and then setting the path accordingly:

     if(index(DocumentPath(),'DEV') > 0) then   (or something similar)