You're currently browsing the Ignition 7.9 docs. Click here to view the latest docs.

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

String jdbcDriver - The name of the JDBC driver in Ignition. Required.

String name - The datasource name. Required.

String description - Description of the datasource

String connectUrl - Default is the connect URL for JDBC driver.

String username - Username to login to the datasource with.

String password - Password for the login.

String props - The extra connection parameters.

String validationQuery - Default is the validation query for the JDBC driver.

Integer maxConnections - Default is 8.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
# 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;")
  • No labels