メインコンテンツにスキップ

JdbcX

This is a Google Apps Script functional library that expands the capabilities of the standard Jdbc class for accelerated processing of queries with support for asynchronous execution.

AI Summary

JdbcX

A Google Apps Script library that extends the built-in Jdbc service to execute SQL faster and asynchronously.

Target Users

Intermediate-to-advanced GAS developers who need to read/write large volumes of data to external SQL databases from internal tools or workflows.

Problems Solved

The native GAS Jdbc service is single-threaded and slow, making it hard to process large data sets or multiple queries efficiently.

Tags

Main Features

1
Speed boost via WebApp backend

Queries are off-loaded to a WebApp that runs in parallel threads, reducing overall execution time.

2
Up to 20 parallel asynchronous calls

Async methods send POST requests handled by the backend, allowing up to 20 concurrent operations from a single GAS script.

3
Rich database helper methods

Utility methods such as insertArrayToDBTable and retrieveDataFromDB simplify INSERT, SELECT and metadata queries.

Usage Examples

Quick SELECT with minimal setup

function quickSelect() {
  // Connection settings
  const config = {
    prefix: "jdbc:mysql://",
    server: "127.0.0.1",
    port: 3306,
    db: "default_db",
    userName: "user",
    password: "password"
  };

  // Create connection via JdbcX
  const conn = JdbcX.getConnection(config);

  // Run a query
  const data = conn.queryDatabase("SELECT * FROM example_table LIMIT 10");

  // Output the result
  console.log(JSON.stringify(data));
}

Copy & run to fetch the first 10 rows from example_table. This is the quickest way to verify that JdbcX works in your environment.