Registry / database / knex-aurora-data-api-mysql

knex-aurora-data-api-mysql

JSON →
library3.0.2jsnpmunverified

A Knex.js driver for MySQL AWS Aurora Data API (version 3.0.2). Allows using Knex.js query builder with Aurora Serverless via HTTP Data API, eliminating connection pooling and server management. Requires knex ^2.4.0. Supports transactions (but not nested), uses AWS SDK v3 (included in Lambda nodejs18.x+). Released irregularly; last update 2023. Different from knex-aurora-data-api-client which supports PostgreSQL and older SDK.

npm install knex-aurora-data-api-mysql
INSTALL
IMPORT
SIG · KNEX-AURORA-DATA-A
K
knex-aurora-data-api-mysql
databasejavascriptv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const knex = require('knex')({ client: require('knex-aurora-data-api-mysql'), connection: {...} })
import knex from 'knex-aurora-data-api-mysql'
Module is not ESM. Use require() or dynamic import(). The module is a Knex client, not a standalone query builder.
knex
const knex = require('knex')({ client: 'knex-aurora-data-api-mysql', connection: {...} })
const knex = require('knex')({ client: require('knex-aurora-data-api-mysql'), connection: {...} }); knex.client = ...
Pass client as string to let knex resolve, or pass the required module directly. Do not reassign client after init.
Knex
const Knex = require('knex'); const knex = Knex({ client: require('knex-aurora-data-api-mysql'), connection: {...} })
const { Knex } = require('knex-aurora-data-api-mysql')
Knex is imported from 'knex', not from this package. This package exports a client object.

Initializes Knex with Aurora Data API MySQL driver and runs a simple SELECT query.

const knex = require('knex')({ client: require('knex-aurora-data-api-mysql'), connection: { database: 'mydb', resourceArn: 'arn:aws:rds:us-west-2:123456789012:cluster:mydbcluster', secretArn: 'arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret', sdkConfig: { region: 'us-west-2', accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '', secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '' } } }); async function main() { const result = await knex('users').where('id', 1).first(); console.log(result); await knex.destroy(); } main().catch(console.error);
Debug
Known issues
gotchaNested transactions are not supported.
fix
Avoid using trx.transaction() inside a transaction. Use a single transaction level.
affects: >=1.0.0
breakingUpgraded to AWS SDK v3 in version 3. SDK configuration changed from region/accessKeyId/secretAccessKey to sdkConfig object.
fix
Wrap AWS config in sdkConfig: { region: '...', accessKeyId: '...', secretAccessKey: '...' }
affects: >=3.0.0
gotchaThe Data API has a maximum response size of 1 MB. Queries returning larger results may fail.
fix
Use pagination or limit queries. Consider streaming with Knex's stream() method.
affects: >=1.0.0
deprecatedVersion 2 used AWS SDK v2. SDK configuration was directly in connection object (region, accessKeyId, secretAccessKey).
fix
Upgrade to v3 and move config to sdkConfig object.
affects: >=2.0.0 <3.0.0
gotchaThis package is for MySQL only. For PostgreSQL, use knex-aurora-data-api-client.
fix
Use correct package for database type.
affects: >=1.0.0
Errors
Common errors & fixes
Error: knex: Unknown client 'knex-aurora-data-api-mysql'
Using client as string without the module being installed or incorrectly passed as require('knex-aurora-data-api-mysql')
fix
Use client: require('knex-aurora-data-api-mysql') or ensure the module is installed and importable.
Cannot find module 'knex-aurora-data-api-mysql'
Package not installed or not in node_modules
fix
Run npm install knex-aurora-data-api-mysql
TypeError: Cannot read properties of undefined (reading 'transaction')
Attempting to create nested transaction (trx.transaction()) which is not supported
fix
Remove nested transaction call. Use a single transaction scope.
CredentialsError: Missing credentials in config
AWS credentials not provided correctly; sdkConfig missing or empty
fix
Provide sdkConfig with region and credentials, or set AWS environment variables.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
knexrequiredpeer dependency - driver requires knex >= 2.4.0
Agent activity
11 hits · last 30 days
node
8
Bingbot
1
Resources
knex-aurora-data-api-mysql — npm install knex-aurora-data-api-mysql · libregistry