Altova DatabaseSpy 2025 Enterprise Edition

Example: Switch Environments

Home Prev Top Next

With Global Resources, you can change not only the database connection, but also reload any SQL scripts that you've defined as Global Resources. This example shows you how Global Resources can help you switch the working environment from a "development" to a "production" one.

 

First, you will create a Global Resource of type "database" that contains two configurations: a "development" and a "production" database. Next, you will create two SQL scripts that query the "development" and the "production" database, respectively. Once this is done, you will be able to quickly switch to the desired environment from the graphical user interface of DatabaseSpy.

 

Step 1: Create the database resources

1.On the Tools menu, click Global Resources. (Alternatively, click the Global Resource _ic_global_resource toolbar button.)

2.Click Add | Database.

3.Enter a descriptive name in the Resource alias text box (for example, "MyDB").

4.Click Choose Database, select the desired connection method (for example, SQLite), and browse for (or connect to) the development database. Notice that the database connection details are attached to the Default configuration.

dbs_gr_example_01

5.Click Add Configuration _ic_add_gr_config and name it "Release".

6.Click Choose Database, select the desired connection method (for example, SQLite), and this time browse for (or connect to) the production database.

dbs_gr_example_06

At this stage, you have created two configurations for the "MyDB" resource:

 

1.Default - points to the development database

2.Release - points to the production database.

 

Step 2: Create the SQL scripts as resources

1.On the Tools menu, click Global Resources. (Alternatively, click the Global Resource _ic_global_resource toolbar button.)

2.Click Add | File.

3.Enter a descriptive name in the Resource alias text box (for example, "MyInsertScript").

4.Under "The Resource will point to this file", click Browse and select a SQL script that contains queries meant for the development database.

5.Click Add Configuration _ic_add_gr_config and name it "Release".

6.Under "The Resource will point to this file", click Browse and select a SQL script that contains queries meant for the production database.

 

At this stage, you have created two configurations for the "MyInsertScript" resource:

 

1.Default - points to a development SQL script

2.Release - points to a production SQL script.

 

Step 3: Switch Environments

1.On the File menu, click New Project.

2.Click Connect to a database ic_quick-connect, or press Ctrl+Q.

3.On the database connection wizard, click Global Resources and select the "MyDB" Global Resource created previously.

4.On the File menu, point to Open | Open Global Resource.

5.Select the "MyInsertScript" resource created previously, and click Open.

dbs_gr_example_03

You can now easily switch between development and production environments, by selecting the desired configuration from the list of active configurations.

dbs_gr_example_04

Each time the environment is reloaded, a message box opens, asking for confirmation, and also indicating the exact resources that are being reloaded, for example:

dbs_gr_example_05

6. Click Reload to confirm the configuration switch.

© 2018-2024 Altova GmbH