Skip to main content
Version: 7.9

system.db.addDatasource

This function is used in Python Scripting.

Description

Adds a new database connection in Ignition.

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.addDatasource(jdbcDriver, name, description, connectUrl, username, password, props, validationQuery, maxConnections)

Parameters

TypeParameterDescription
StringjdbcDriverThe name of the JDBC driver in Ignition. Required.
StringnameThe datasource name. Required.
StringdescriptionDescription of the datasource
StringconnectUrlDefault is the connect URL for JDBC driver.
StringusernameUsername to login to the datasource with.
StringpasswordPassword for the login.
StringpropsThe extra connection parameters.
StringvalidationQueryDefault is the validation query for the JDBC driver.
IntegermaxConnectionsDefault is 8.

Returns

Nothing

Scope

All

Code Examples

Example #1
# The following code would add a MySQL connection to the Gateway.
system.db.addDatasource(jdbcDriver="MySQL ConnectorJ", name="MySQL",
connectURL="jdbc:mysql://localhost:3306/test", username="root",
password="password", props="zeroDateTimeBehavior=convertToNull;")