Registry / database / csv-to-sql

csv-to-sql

JSON →
library0.1.14jsnpmunverified

A lightweight Node.js library for converting CSV files into SQL INSERT statements. Version 0.1.14 is the latest stable release, updated irregularly. It provides a simple CLI and programmatic API to parse CSV data and generate SQL scripts, with options for table naming and batch processing. Differentiators: minimal dependencies, straightforward output, no database connection required. Suitable for quick data migrations or backups.

npm install csv-to-sql
INSTALL
IMPORT
SIG · CSV-TO-SQL
C
csv-to-sql
databasejavascriptv0.1.14
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.

convert
✓ import { convert } from 'csv-to-sql'
✗ const convert = require('csv-to-sql').convert
ESM-only; CommonJS require may fail or require default import.
default
✓ import csvToSql from 'csv-to-sql'
✗ const csvToSql = require('csv-to-sql')
Default export is the main convert function. Using require might give an object with convert property.
convert
✓ import { convert } from 'csv-to-sql'
The library does not export other symbols; ensure correct named import.

Converts a CSV string to SQL INSERT statements with a specified table name.

import { convert } from 'csv-to-sql'; const csv = `id,name,age\n1,Alice,30\n2,Bob,25`; const sql = convert(csv, { table: 'users' }); console.log(sql); // Output: // INSERT INTO users (id, name, age) VALUES (1, 'Alice', 30); // INSERT INTO users (id, name, age) VALUES (2, 'Bob', 25);
Debug
Known issues
gotchaCSV values containing single quotes are not escaped and will break SQL.
fix
Preprocess CSV to escape single quotes or use a more robust library.
affects: <=0.1.14
deprecatedThe CLI interface may be removed in future versions without notice.
fix
Use programmatic API instead of CLI for stability.
affects: >=0.1.0
gotchaOutput always uses INSERT INTO statements; no support for other SQL dialects.
fix
Manually transform output if needed for different SQL syntax.
affects: all
breakingPrevious versions used CommonJS; v0.1.0+ switched to ESM only.
fix
Use dynamic import or ensure ESM environment.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'csv-to-sql'
Module not installed or wrong import path.
fix
Run 'npm install csv-to-sql' and use correct import: import { convert } from 'csv-to-sql'
SyntaxError: Unexpected token 'export'
Using require() on an ESM-only module in CommonJS.
fix
Use dynamic import() or set type: 'module' in package.json.
TypeError: convert is not a function
Wrong import style; destructured incorrectly.
fix
Use import { convert } from 'csv-to-sql'; or import csvToSql from 'csv-to-sql';.
Error: Invalid CSV format
CSV does not have consistent columns or malformed data.
fix
Ensure CSV is properly formatted with same number of columns per row.
Upgrade
Version history
0.1.14latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
csv-to-sql — npm install csv-to-sql · libregistry