A simple wrapper collection of utilities for handling MySQL connections and pools.
Contains:
basicMySqlInsert
- From the basic connection executes an insert given the specified fields as a set of parallel arrays. Very rudimentary checking and safety.getPoolConfig
- Uses a standard set of environment variables to construct a templated config. See below for vars.getConnectionPool
- Grabs the existing or creates a new pool from the config options.safeReleaseConnection
- Releases a connection back to the pool, but doesn't error if the connection is undefined.getConnection
- Grab a connection from the pool.closeConnectionPool
- Closes all connections in the pool, and the pool itself.
MYSQL_CONNECT_TIMEOUT
(int, default 2000)MYSQL_CONNECTION_POOL_SIZE
(int, default 5)MYSQL_DATABASE
requiredMYSQL_DEBUG
(boolean, default false)MYSQL_HOST
requiredMYSQL_PASSWORD
requiredMYSQL_PORT
(int, default 3306)MYSQL_USER
required
Before running npm test
, make sure you have a database with a simple test table accessible at the credentials
specified in .env.test
. You can run up a container using npm db:up
and teardown using npm db:down
.
The workflow files for this repo require the NODE_VERSION and NPM_VERSION var to be specified.
gh auth login
gh variable set NODE_VERSION -b "20.15.1"
gh variable set NPM_VERSION -b "10.8.2"