Programically Change Database Connection?

I would like to be able to set the Connect URL, and the Database name in a Database connection on the gateway using a python script.

Is this possible? If so how would I go about it?

You can change the connect URL dynamically:
However, changing the name would be inadvisable. Everything in Ignition is keyed off the database name, so things may break unexpectedly. If you’re not concerned about that, you could remove and then add new database connection: