Training version of project

I’ve created a version of a project as a sandbox for new users to play in without harming the actual production database, and I’ve hit a roadblock. The training project connects to a database which is a copy restored from the previous day’s backup of our production database. I have created a stored procedure to check for that backup, and if it exists drop the training database and recreate it from that backup.

The problem is that I can’t find a good way to automate this procedure in a job. The procedure itself runs fine when there are no connections to the training database. But it seems like there is always a “sleeping” connection until I disable the database connection from the Ignition server.

Is there a way to disable and then re-enable that database connection on a regular basis? Or is there just a better way to approach this problem completely?

looks like there is a way to disable/enable a datasource using the scripting module


So something like this…

system.db.setDatasourceEnabled("training_switchboard", False)

…turns it off, and then run it again with True to turn it on.

Ideally I’d want to sync that with the stored procedure and/or the job, but it would probably suffice to just set the disconnect and reconnect scripts up as Gateway Event scripts, such that the sql server job would run between them. Sound about right?