Perl DBI

4 minute readExtensibilityDeveloper productivity

The Perl DBI module is a simple Perl database interface used to execute queries. The Perl DBI module executes a query through an appropriate database driver (DBD) module.

A DBD module has the required libraries needed to communicate to a database. When you use the Perl DBI module to make a query, it sends the query to the corresponding DBD module to communicate directly to the database.

With the EC-DBI plugin, you can:

  • Execute SQL scripts from SQL files or from the text area in the parameter form.

  • Create backups for your databases.

The plugin executes the SQL code against databases by using the Perl DBI module, which means that you must install the corresponding DBD module. DBD-mysql and DBD-ODBC are installed by default, which means that you can access MYSQL and SQL Server or any preconfigured ODBC connection by default. Additional DBD Modules are required for Oracle, Postgres, and SQLite. Additionally, it can back up databases by calling command-line tools for almost every database type. For example, MySQL uses mysqldump, SQL Server uses osql, Oracle uses exp, and Postgres usespg_dump.

This plugin can communicate with the following databases:

  • SQL Server (through ODBC) 2008

  • MySQL 5.5

  • Oracle 9.2 or later

  • SQLite 3.7.7

  • Postgres 8.4 or later

Plugin Version 2.0.4.2020102201 Revised on July 1, 2015

More information can be found at this website.

Perl DBD modules can be found at this website.

Setting up the plugin configuration

For all parameter descriptions below, required parameters are shown in bold italics.
In the CloudBees CD UI, go to the Home page, open the Main Menu, and click Admin Plugins to open the Plugin Manager.

Plugin configurations are sets of parameters that apply across some or all of the plugin’s procedures. They reduce repetition of common values, create predefined sets of parameters for end users, and securely store credentials where needed. Each configuration is given a unique name that is entered in designated parameters on procedures that use them.

To create a plugin configuration, go to the CloudBees CD "Administration" tab, then to the "Plugins" subtab. On the right side of the line for the specific plugin, click the "Configure" link to open the Configuration page.

Plugin configuration parameters

ParameterDescription

Configuration Name

Provide a unique name for the configuration. (Required)

User Name

Provide the user login ID for your database connection. (Required)

Password

Provide the user-specified password. (Required)

Plugin procedures

ExecuteQuery

This procedure creates a database connection through the Perl DBI module and a Perl DBD module to execute an SQL statement against the corresponding database.

You can access any database indirectly by using a preconfigured ODBC.

Additional Perl modules are required for the following databases:

DatabaseModule nameCPAN reference

Oracle

DBD-Oracle

DBD-Oracle at CPAN

SQLite

DBD-SQLite

DBD-SQLite at CPAN

Postgres

DBD-Pg

DBD-Pg at CPAN

ParameterDescription

Database engine

Choose the database engine you want to connect to. Available options are: SQLServer, MySql, Oracle, Sqlite, Postgres, or an ODBC connection to any database. (Required)

Database name

The name of the database you want to use. (Required)

Server

Database server name. (Required)

Port

Database port. Common default ports are:

  • 3306 (Mysql)

  • 1433 (SQLServer)

  • 1521 (Oracle)

  • 5432 (Postgres)

Enable transactions

If checked, this option protects your data in case of errors.

Display format

Choose a display format. (Required)

Sql query

The query to run against the database.

Sql file

Absolute path to a SQL script.

Configuration name

Name of the configuration that contains the database user and password. (Required)

Result (output property path)

Property name used to store the result of queries.

BackUpDB

Creates a backup for the specified database.

ParameterDescription

Database engine

Choose the database engine you want to connect to. Available options are: SQLServer, MySql, Oracle, Postgres and Sqlite. (Required)

Command Line Utility

Absolute path to a backup command utility. (Required):

  • mysqldump (Mysql)

  • osql (SQLServer)

  • exp (Oracle)

  • pg_dump (Postgres)

Database name

The name of the database to back up. (Required)

Server

Database server name.

Port

Database port. Some of the default ports are:

  • 3306 (Mysql)

  • 1433 (SQLServer)

  • 1521 (Oracle)

  • 5432 (Postgres)

Configuration name

Name of the configuration that contains the database user and password. (Required)

Name of the backup file

Name of the backup file (without extension). If you leave the field blank, the file name is "backup".

Destination path

The path where you want to store your backup file. (Required)

Examples and use cases

The following example shows how to create a configuration:

The following example shows a list of server configurations:

The following example shows a completed ExecuteQuery parameter form:

The following example shows output for ExecuteQuery:

The following example shows a completed MySql backup parameter form:

The following example shows output for a MySQL backup:

The following example shows a completed Oracle backup parameter form:

The following example shows output for an Oracle backup:

The following example shows a completed SQL Server backup parameter form:

The following example shows output for a SQL Server backup:

Release notes

EC-DBI 2.0.4

  • The documentation has been migrated to the main documentation site.

EC-DBI 2.0.3

  • Added metadata that is required for 9.0 release.

EC-DBI 2.0.2

  • Fixed issue with configurations being cached for IE.

EC-DBI 2.0.1

  • ElectricCommander was renamed to CloudBees CD.

EC-DBI 2.0.0

  • The result (output property path) parameter was added.

  • JSON and XML formats for results were added.

EC-DBI 1.0.2

  • Procedure names were changed in the step picker section.

EC-DBI 1.0.1

  • XML parameter panels were added.

  • The Help page was updated.

EC-DBI 1.0.0

  • Initial release.