{"id":42566,"library":"csv-mysql","title":"csv-mysql","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/rajaru/csv-mysql","tags":["javascript","csv","mysql","node"],"install":[{"cmd":"npm install csv-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add csv-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add csv-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"CSV parsing","package":"csv","optional":false},{"reason":"MySQL database driver","package":"mysql","optional":false}],"imports":[{"note":"This package uses CommonJS; default export is not available via ESM import.","wrong":"import cm from 'csv-mysql';","symbol":"import","correct":"const cm = require('csv-mysql');"}],"quickstart":{"code":"const cm = require('csv-mysql');\n\nconst data = '\"c1\",\"c2\",\"c3\"\\n\"1\",\"2\",\"3\"\\n\"4\",\"5\",\"6\"';\nconst options = {\n  mysql: {\n    host: '127.0.0.1',\n    user: 'root',\n    database: 'test',\n    password: process.env.MYSQL_PASSWORD ?? ''\n  },\n  csv: {\n    comment: '#',\n    quote: '\"'\n  },\n  table: 'test'\n};\n\ncm.import(options, data, function(err, rows) {\n  if (err) {\n    console.error(err);\n  } else {\n    console.log('Inserted rows:', rows);\n  }\n});","lang":"javascript","description":"Demonstrates using csv-mysql to import CSV string into MySQL table with connection options and callback."},"warnings":[{"fix":"Create the table in MySQL before calling cm.import().","message":"Target table must exist before importing; the module does not create tables.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure CSV headers match MySQL column names exactly.","message":"Column validation is case-sensitive; headers must match column names exactly.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use const cm = require('csv-mysql');","message":"Only CommonJS require is supported. Using ES6 import will fail.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.3':21 'activ':31 'addit':77 'api':64 'batch':73 'column':35,39 'creat':43 'csv':2,4,51,67,80 'csv-mysql':1 'current':24 'data':78 'databas':59 'depend':47 'develop':32 'differenti':62 'extran':38 'fast':66 'fix':76 'import':7,68 'indic':30 'insert':16 'javascript':79 'key':61 'like':71 'maxrow':72 'multi':14 'multi-valu':13 'mysql':3,6,57,81 'node':50,56,82 'node-csv':49 'node-mysql':55 'node.js':10 'oper':60 'option':70 'pars':53 'perform':19 'recent':28 'releas':26 'simpl':63 'size':74 'skip':37 'stabl':25 'statement':17 'tabl':46 'target':45 'tool':8 'updat':29 'use':12 'valid':34 'valu':15 'version':20","created_at":"2026-06-05T16:55:35.719000+00:00","updated_at":"2026-06-05T16:55:35.719000+00:00","problems":[{"fix":"Create the table in MySQL first.","cause":"Target table not created before import.","error":"Error: ER_NO_SUCH_TABLE: Table 'test.test' doesn't exist"},{"fix":"Change import to const cm = require('csv-mysql');","cause":"Attempting to use ES6 import instead of CommonJS require.","error":"TypeError: cm.import is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/rajaru/csv-mysql#readme","github":"https://github.com/rajaru/csv-mysql","docs":null,"changelog":null,"pypi":null,"npm":"csv-mysql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}