Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the environment variable in the connection string for the database in the genbil #682

Open
Longwinter93 opened this issue Jun 5, 2022 · 14 comments

Comments

@Longwinter93
Copy link

Longwinter93 commented Jun 5, 2022

Hi,
I usually load a set of my test cases from my database like:
case load query 'Relative Directory\myQuery.sql' on 'Data Source=...';

However, I was wondering if it is possible to place the environment variable in the connection string for the database instead of 'Data Source=...';
For example:
case load query 'Relative Directory\myQuery.sql' on 'environment name ="Database"';

Unfortunately, this example does not work. Obviously, I took a few tests, where I changed this syntax, but none of my ideas works..

Could you please tell me if it is possible to implement the environment variable in this connection string for the database?
If so, would you be so kind as to advise me how to deal with it?

I would appreciate it if you could share any ideas with me.

Thanks in advance!

@Seddryck
Copy link
Owner

Seddryck commented Jun 8, 2022

There is no support of environment variables within genbiL.

This should be implemented as a new feature.

@Longwinter93
Copy link
Author

Hi! Thank you for your answer.

It seems that this feature would be extremely useful and helpful.

Could you please tell me if you implement it soon ?

Should I create a new pull request about it ?

I would appreciate it if you could tell me about it.

Best regards,
Lukasz

@Seddryck
Copy link
Owner

Seddryck commented Jun 8, 2022 via email

@Longwinter93
Copy link
Author

Hi,
Thank you for your advice and response !

I will try to handle this problem once again and inform you about it provided that it works.

If you find this solution earlier, I will be thankful if you share it with me.

Therefore, we keep in touch!

Best regards,
Lukasz

@Seddryck
Copy link
Owner

Seddryck commented Jun 8, 2022

I hope that this version is adding the feature. To reference an environment variable use the following syntax

case load query 'Relative Directory\myQuery.sql' on $env:Database;

where Database is the name of the environment variable.

Could you confirm that it's matching with your need? If yes, I'll merge and create a beta.

@Longwinter93
Copy link
Author

Hi!,

Thank you for your contribution to it.

I downloaded Framework.zip and UI.zip files in order to run my genbiL.
Unfortunately, if I open my genbiL files with your syntax, I will encounter difficulties in opening it. This failure appears: "Object reference not set to an instance of an object".

However, if I open the normal genbiL files without this syntax, it will work.

I tried to open these nupkg files by Visual Studio , but it did not work as well..

Therefore, could you please try to fix it and inform me about it ? Then, I will test it.

If I run it wrongly, can you advise me how to open it properly to run my genbiL with your syntax ?

I would appreciate it if you could fix it.

Best Regards,
Lukasz

@Seddryck
Copy link
Owner

Seddryck commented Jun 9, 2022

Could you share your file?

@Longwinter93
Copy link
Author

Longwinter93 commented Jun 9, 2022

Hi,
Do you mean a genbiL file ?

If so, these codes are included there:

case load query 'Relative_Directory\myQuery.sql' on $env:Database;
template load file 'Relative_Directory\Template.nbitt';
suite generate;
setting default assert connectionString '<environment name ="A"/>';
setting default systemundertest connectionString '<environment name ="B"/>';
suite save 'Relative_Directory\Save.nbits';

If no, could you please tell me which ones you need ?

@Seddryck
Copy link
Owner

I published a new version that should be working: https://ci.appveyor.com/project/Seddryck/nbi/builds/43833902/artifacts

@Longwinter93
Copy link
Author

Hi,
Thank you for your contribution to it.
Could you please tell me which files I need to download from this link to try it ?

It seems that I should download Framework.zip and UI.zip. Is it correct ?

I would appreciate it if you could advise me which ones are necessary to test it.

Thanks in advance !

@Seddryck
Copy link
Owner

I'd say that UI.zip should be enough, changes are limited to genbiL.

@Longwinter93
Copy link
Author

Hi!,

I put this code, which I sent you, to a genbiL file and when I run my macro I received this information:
"Exception generated during execution of the macro.
connectionString
The connection string cannot be null or empty."

I checked my environment variables in Windows and all of them has connection strings.

Could you please tell me how you modify your genbiL file that works properly ?

I am not aware where I made a mistake.

Best Regards,
Lukasz

@Longwinter93
Copy link
Author

Longwinter93 commented Jun 14, 2022

Hi!,
I tried it once again and it works successfully!

I needed to change locally my environment variables in Windows with respect to this structure: 'Data source:...'
Then, I needed to run this Genbi as a administrator.

I would like to inquire about this modification.
Are you going to implement it in the upcoming release ?
If so, when are you going to do it ??

Thank you for your contribution and aid in this modification!

Best Regards,
Lukasz

@Seddryck
Copy link
Owner

Yes, it will be integrated into the next release. After some additional review, I'll write down some documentation and push to the develop branch. That will generate a new beta.

There is no difference between a beta and a release except the naming. I don't know when I'll publish a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants