Registry / database / csv-mysql

csv-mysql

JSON →
library1.0.3jsnpmunverified

CSV to MySQL import tool for Node.js that uses multi-valued INSERT statements for performance. Version 1.0.3 is the current stable release; no recent updates indicate active development. It validates columns and skips extraneous columns, but does not create the target table. Depends on node-csv for parsing and node-mysql for database operations. Key differentiator: simple API for fast CSV imports with options like maxrows batch size and fixed additional data.

npm install csv-mysql
INSTALL
IMPORT
SIG · CSV-MYSQL
C
csv-mysql
databasejavascriptv1.0.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.

import
✓ const cm = require('csv-mysql');
✗ import cm from 'csv-mysql';
This package uses CommonJS; default export is not available via ESM import.

Demonstrates using csv-mysql to import CSV string into MySQL table with connection options and callback.

const cm = require('csv-mysql'); const data = '"c1","c2","c3"\n"1","2","3"\n"4","5","6"'; const options = { mysql: { host: '127.0.0.1', user: 'root', database: 'test', password: process.env.MYSQL_PASSWORD ?? '' }, csv: { comment: '#', quote: '"' }, table: 'test' }; cm.import(options, data, function(err, rows) { if (err) { console.error(err); } else { console.log('Inserted rows:', rows); } });
Debug
Known issues
gotchaTarget table must exist before importing; the module does not create tables.
fix
Create the table in MySQL before calling cm.import().
affects: >=0.0.0
gotchaColumn validation is case-sensitive; headers must match column names exactly.
fix
Ensure CSV headers match MySQL column names exactly.
affects: >=0.0.0
gotchaOnly CommonJS require is supported. Using ES6 import will fail.
fix
Use const cm = require('csv-mysql');
affects: >=0.0.0
Errors
Common errors & fixes
Error: ER_NO_SUCH_TABLE: Table 'test.test' doesn't exist
Target table not created before import.
fix
Create the table in MySQL first.
TypeError: cm.import is not a function
Attempting to use ES6 import instead of CommonJS require.
fix
Change import to const cm = require('csv-mysql');
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
csvrequiredCSV parsing
mysqlrequiredMySQL database driver
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
csv-mysql — npm install csv-mysql · libregistry