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:
https://docs.inductiveautomation.com/display/DOC81/system.db.setDatasourceConnectURL
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:
https://docs.inductiveautomation.com/display/DOC81/system.db.removeDatasource
https://docs.inductiveautomation.com/display/DOC81/system.db.addDatasource