system.db.setDatasourceEnabled
This function is used in Python Scripting.
Descriptionβ
Enables/disables a given database connection.
Client Permission Restrictionsβ
Permission Type: Datasource Management
Client access to this scripting function is blocked to users that do not meet the role/zone requirements for the above permission type. This function is unaffected when run in the Gateway scope.
Syntaxβ
system.db.setDatasourceEnabled(name, enabled)
Parametersβ
| Type | Parameter | Description |
|---|---|---|
| String | name | The name of the database connection in Ignition. |
| Boolean | enabled | Enables/disables a given database connection. |
Returnsβ
Nothing
Scopeβ
Gateway, Vision Client, Perspective Session
Code Examplesβ
Code Snippet - Enabling a Database Connection
# Enable the database named "MySQL"
system.db.setDatasourceEnabled("MySQL", 1)
Code Snippet - Disabling a Database Connection
# Disable the database named "MySQL"
system.db.setDatasourceEnabled("MySQL", 0)