Is there an option to Dynamically change data source in Qlik sense?
For example, I have three streams(DEV, UAT, PROD ) and I need to connect to three different data sources(DEV, UAT, PROD),
Is there a way like I should not change the connection string but it should pick up the data source dynamically when I deploy in respective streams(DEV, UAT, PROD)? Can you please reply. Thanks in advance!
I personally haven't tried anything regarding this, but the first thing comes to mind is an IF ELSE statement using a source-path that would be included in the script. Then when you "deploy" to a stream the files would change locations/paths. Therefore the script would automatically account for it.
A few functions that come to mind to get a path...
Please let me know if you end up finding a viable solution. If I end up finding time to test this I will reply back.
If the Source is file system, then we can apply IF ELSE and use the functions which you mentioned.
what if we are using OLEDB conection to connect to SQL server?
the ideal solution for this would be, We need some qlik function to identify the stream Name, that way we can apply IF ELSE and swap the connections.
First of all you need to create 4 data connection. DEV, UAT, PROD and POSTGRE_QSR(qlik sense database). We need QSR connection to fetch the stream name of the app.
let appId = DocumentName();
LIB CONNECT TO 'POSTGRE_QSR';
ID as AppID,
Name as StreamName;
FROM public."Apps" app
left join public."Streams" str on app."Stream_ID"=str."ID"
let DataSourceName = peek('StreamName');
DROP TABLE Temp_App_Stream;
LIB CONNECT TO '$(DataSourceName)';
If you get the logic, you are able to modify this script based on your needs.
Hope it helps.
Thanks for this solution. I plan to use it for the same problem the OP has described.
Does it bring a security issue in your opinion? And if yes, how could this be handled?
(In my environment, many apps with several developers would profit from using this mechanism in their scripts: Based on the stream, folder connections for include commands and for QVD data read/write could be switched when an app goes from a DEV stream to a PROD stream. But then, the qliksense service user need to have access to the repository db connection. Using this, any developer can fully read the repository, after its app has been published... We have just started the migration from QlikView to Qlik Sense. So, my knowledge is still very limited. Please excuse if my question does not make sense...)