Registry / database / excel-to-mysql

excel-to-mysql

JSON →
library2.6.3jsnpmunverified

Converts Excel spreadsheets (XLS/XLSX/CSV) into MySQL tables, supporting both direct database insertion and SQL file generation. Current stable version is 2.6.3 (infrequent releases). It requires a pre-existing database and table name. Peer dependency on 'mysql' package. Key differentiators: supports custom row/column start/end, auto-increment IDs, verbose logging, and safe mode backup. Alternatives like 'xlsx-to-mysql' offer similar functionality. Note: The module has a typo in the main function name 'covertToMYSQL' which is intentionally misspelled.

npm install excel-to-mysql
INSTALL
IMPORT
SIG · EXCEL-TO-MYSQL
E
excel-to-mysql
databasejavascriptv2.6.3
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.

covertToMYSQL
import { covertToMYSQL } from 'excel-to-mysql'
const excelMysql = require('excel-to-mysql'); excelMysql.covertToMYSQL(...)
ESM and CJS both work but the main function has a typo in its name (covert not convert).
convertToFile
import { convertToFile } from 'excel-to-mysql'
const { convertToFile } = require('excel-to-mysql');
Correct name for SQL file generation. Note that the sibling function 'covertToMYSQL' is misspelled.
excelMysql
const excelMysql = require('excel-to-mysql');
import excelMysql from 'excel-to-mysql';
Default import is not supported in ESM; this package only provides named exports. Use CJS require or named import.

Shows basic usage: import the module, set up credentials (with environment variables for security), and call covertToMYSQL to insert Excel data into a MySQL table.

const { covertToMYSQL } = require('excel-to-mysql'); const credentials = { host: process.env.DB_HOST ?? 'localhost', port: 3306, user: process.env.DB_USER ?? 'root', pass: process.env.DB_PASS ?? '', path: './data.xlsx', table: 'my_table', db: 'test_db', endConnection: true, }; const options = { verbose: true, autoId: false }; covertToMYSQL(credentials, options, (err, result) => { if (err) console.error(err); else console.log('Data imported successfully'); });
Debug
Known issues
gotchaThe main function name is misspelled as 'covertToMYSQL' (missing 'n' in 'convert'). This is intentional and will not be fixed. Using 'convertToMYSQL' will cause a ReferenceError.
fix
Always use the exact function name 'covertToMYSQL' when calling.
affects: all
deprecatedThe repository has no recent updates and may not support newer Node.js versions or MySQL 8+ authentication plugins. The last commit was years ago.
fix
Consider using more actively maintained alternatives like 'xlsx-to-mysql' or writing custom code with 'xlsx' and 'mysql2'.
affects: all
gotchaSetting endConnection to false may prevent the Node process from exiting. The documentation warns: 'endConnection false may not terminate the process.'
fix
Always set endConnection: true unless you have a specific reason to keep the connection open and manage it externally.
affects: all
breakingIn version 2.x, the function signatures changed. The callback is now the third argument, and options were restructured. Old code passing callback as second argument will break.
fix
Update calls to use (credentials, options, callback) signature. Check the changelog for exact migration.
affects: <2.0.0 || >=2.0.0
Errors
Common errors & fixes
ReferenceError: convertToMYSQL is not defined
Using the correctly spelled function name 'convertToMYSQL' which does not exist.
fix
Use the exact function name 'covertToMYSQL' (with 'o' instead of 'n' after 'c').
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL 8+ uses caching_sha2_password by default, which may not be compatible with the older 'mysql' package used by this module.
fix
ALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password'; Or switch to 'mysql2' package and adjust the module's connection.
TypeError: Cannot read property 'forEach' of undefined
Excel file path is incorrect or file is empty. The module expects a valid file with at least one row of data.
fix
Double-check the file path and ensure the spreadsheet is not empty and has headers in the first row.
Upgrade
Version history
2.6.3latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency — required for MySQL connections and queries
Agent activity
9 hits · last 30 days
node
8
Resources
excel-to-mysql — npm install excel-to-mysql · libregistry