Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ruthvikvn
Contributor II
Contributor II

how to automate application (qvw) switch between development and production database connection string?

I am trying to automate application(qvw) move from test > QA > Prod of qlikview applications. My roadblock being able to determine the environment via scripting without qlikview admin having to change database connection string when application move is made between different environments. has anyone done this ? Any suggestions would be helpful.

Thanks

Ruthvik.V.N

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

A common solution is to use the $Include() script directive to pull in the connection string from a relative path.

$(Include=scripts\ConnectErp.qvs)

In the development directory tree, the scripts\ConnectErp.qvs file contains the CONNECT statement for the dev database. In the production dir tree the file contains a production CONNECT string. No change is required to the qvw as it moves between environments.

-Rob

View solution in original post

5 Replies
Miguel_Angel_Baeyens

Hello Ruthvik,

Don't know if this may help but I do something as simple as

SET vUnderDevelopment = 1; // 0 = Deployed / 1 = Development IF ($(vUnderDevelopment) = 0) THEN CONNECT TO ODBC Production; SET vPath = 'D:\Data\QV\';ELSE CONNECT TO ODBC Development; SET vPath = 'C:\MyDocuments\QV-Projects\';END IF Customers:LOAD *FROM $(vPath)CUSTOMERS.QVD (qvd);


Sometimes I even allow the user to select the environment via input box.

Hope that helps.

pdumas
Partner - Contributor III
Partner - Contributor III

Hi,

It is best practice to separate application code and file/table description in order to be able to put code into production without changing it.

I have set a generic method to achieve that goal. Principles are :

The DEV docs are suffixed by "dev", e.g. myApp.qvw is named myAppDev.qvw in the dev environment.

In the script, the "documentname()" function is used to assign the Dev/Prod switch value

File/Table descriptions (name, directory,..) are in an excel sheet

In the script, once the sheet is read, I use the "map" statement and "applymap" function to load file description into variables

The variables are then used in the Load statment

It took me some times to write a good reusable code, but now it saves a lot of time and allows production people to play as they want with the server directories, change DB passwords,... without any change in the application code.

Regards

Pierre.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

A common solution is to use the $Include() script directive to pull in the connection string from a relative path.

$(Include=scripts\ConnectErp.qvs)

In the development directory tree, the scripts\ConnectErp.qvs file contains the CONNECT statement for the dev database. In the production dir tree the file contains a production CONNECT string. No change is required to the qvw as it moves between environments.

-Rob

ruthvikvn
Contributor II
Contributor II
Author

Thanks For you quick reply. It did work but I wanted something where Admins would not have to edit script at all . $include() method suggested by Rob does exactly what I was looking for.

Ruthvik.V.N

anjali0108
Partner - Creator III
Partner - Creator III

Hi Rob,

Could you please explain this in detail ?

Even I want to do this.Also,if I will use this script, will it automatically work when I will move my application folder from UAT servers to production servers without making any changes in it.

Also where can I find this folder that you mentioned.

Thanks.