Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The action can be used whenever you want to run a MySQL command before or after a data pipeline. For example, you might want to run a SQL update command on a database before the pipeline source pulls data from tables.

Configuration

Property

Macro Enabled?

Version Introduced

Description

Driver Name

No

Required. Name of the JDBC driver to use.

Default is cloudsql-mysql.

Database

No

Yes
(6.10.0)

Required. MySQL database name.

Username

Yes

Optional. User identity for connecting to the specified database.

Password

Yes

Optional. Password to use to connect to the specified database.

CloudSQL Instance Type

No

Optional. Whether the CloudSQL instance to connect to is private or public.

Default is Public.

Connection Name

No

Yes
(6.10.0)

Required. The CloudSQL instance to connect to in the format <PROJECT_ID>:<REGION>:<INSTANCE_NAME>. Can be found in the instance overview page.

Port

Yes

6.10.0

Optional. Port that MySQL is running on.

Default is 3306.

Database Command

Yes

Required. Database command to execute.

Connection Timeout

No

Optional. The timeout value (in seconds) used for socket connect operations. If connecting to the server takes longer than this value, the connection is broken. A value of 0 means that it is disabled.

Default is 10.

Connection Arguments

Yes

Optional. A list of arbitrary string key/value pairs as connection arguments. These arguments will be passed to the JDBC driver as connection arguments for JDBC drivers that may need additional configurations.

Examples

Connecting to a public CloudSQL MySQL instance

Suppose you want to execute a query against a CloudSQL MySQL database named “prod”, as “root” user with “root” password (Get the latest version of the CloudSQL socket factory jar with driver and dependencies here, and then configure plugin with:

Property

Value

Driver Name

cloudsql-mysql

Database

prod

Username

root

Password

root

CloudSQL Instance Type

Public

Connection Name

[PROJECT_ID]:[REGION]:[INSTANCE_NAME]

Database Command

UPDATE table_name SET price = 20 WHERE ID = 6

Connecting to a private CloudSQL MySQL instance

...

Get the latest version of the CloudSQL socket factory jar with driver and dependencies from the Hub, and then configure the plugin with:

Property

Value

Driver Name

cloudsql-mysql

Database

prod

Username

root

Password

root

CloudSQL Instance Type

Private

Connection Name

[PROJECT_ID]:[REGION]:[INSTANCE_NAME]

Database Command

UPDATE table_name SET price = 20 WHERE ID = 6