Registry / database / dynamodb-to-mysql

dynamodb-to-mysql

JSON →
library1.0.6jsnpmunverified

Seamlessly transfer DynamoDB tables to MySQL server with automatic table structure updates via ALTER TABLE. Version 1.0.6 is the latest stable release, with infrequent updates. Supports parallel scanning via @shelf/dynamodb-parallel-scan and adjustable concurrency. Suitable for production environments to run complex queries on MySQL 8 without PartiQL. Differentiators: automatic schema evolution on repeated runs, configurable MySQL engine/charset, and verbose mode. Uses promise-mysql for async MySQL operations.

npm install dynamodb-to-mysql
INSTALL
IMPORT
SIG · DYNAMODB-TO-MYSQL
D
dynamodb-to-mysql
databasejavascriptv1.0.6
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.

dynamodb2MySQL
import { dynamodb2MySQL } from 'dynamodb-to-mysql'
const dynamodb2MySQL = require('dynamodb-to-mysql').dynamodb2MySQL
Package provides ESM exports; CommonJS require with destructuring works but is non-standard.
dynamodb2MySQLAllTables
import { dynamodb2MySQLAllTables } from 'dynamodb-to-mysql'
const { dynamodb2MySQLAllTables } = require('dynamodb-to-mysql')
Same as above; prefers ESM imports.
[Default export]
Not available
import dynamodb2MySQL from 'dynamodb-to-mysql'
There is no default export; only named exports dynamodb2MySQL and dynamodb2MySQLAllTables.

Demonstrates importing and using dynamodb2MySQL to transfer a single DynamoDB table to MySQL. Environment variables must be set beforehand.

import { dynamodb2MySQL } from 'dynamodb-to-mysql'; import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; // Ensure environment variables are set: // MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE // Optional: MYSQL_CHARSET, MYSQL_ENGINE, CONCURRENCY, VERBOSE const tableName = 'YourDynamoDBTable'; const truncateBeforeInsert = false; // set true to truncate MySQL table before insert dynamodb2MySQL(tableName, truncateBeforeInsert) .then(() => console.log('Transfer complete')) .catch(err => console.error(err));
Debug
Known issues
gotchaEnvironment variables MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE must be set before calling any function; otherwise connection fails.
fix
Set the required environment variables in your shell or process before invoking the library.
affects: >=1.0.0
gotchaThe function dynamodb2MySQLAllTables(truncate) exports ALL tables in the configured AWS region to MySQL. This may cause unintended data overwrites if MySQL tables already exist and truncate is true.
fix
Ensure you intend to transfer all tables; use dynamodb2MySQL for specific tables.
affects: >=1.0.0
gotchaThe package uses promise-mysql which returns connection pools; ensure proper cleanup to avoid hanging connections in long-running processes.
fix
Call connection.end() after transfer or use the library's internal cleanup (if any); otherwise manage connections manually.
affects: >=1.0.0
breakingNo known breaking changes as version 1.0.6 is the only stable release; API is stable.
fix
None.
affects: >=1.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED ...:3306
MySQL host or port not reachable; environment variables MYSQL_HOST may be incorrect or MySQL not running.
fix
Verify MYSQL_HOST and ensure MySQL server is accessible from the running environment.
Error: Cannot find module '@aws-sdk/client-dynamodb'
Missing required dependency @aws-sdk/client-dynamodb; not installed as peer dependency.
fix
Run: npm install @aws-sdk/client-dynamodb
Error: AccessDeniedException: ...
AWS IAM role/user does not have dynamodb:DescribeTable and dynamodb:Scan permissions.
fix
Add the required IAM policy as described in the README.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
@aws-sdk/client-dynamodbrequiredAWS SDK for DynamoDB interactions (describe, scan)
@shelf/dynamodb-parallel-scanrequiredParallel scanning of DynamoDB tables for performance
promise-mysqlrequiredMySQL connection and query execution with promises
Agent activity
8 hits · last 30 days
node
6
Resources
dynamodb-to-mysql — npm install dynamodb-to-mysql · libregistry