Registry / database / mysql-extractor

mysql-extractor

JSON →
library0.4.4jsnpmunverified

Node.js package (v0.4.4) that extracts a MySQL database schema into JSON files for tables, foreign keys, indexes, and issues. Designed to facilitate migrations by outputting structured schema representations, including column types, constraints, and known naming/type issues. The library supports a range of MySQL column types and provides filtering options via callback. It offers minimal dependencies and a straightforward API. Development appears to be in maintenance mode with no recent updates.

npm install mysql-extractor
INSTALL
IMPORT
SIG · MYSQL-EXTRACTOR
M
mysql-extractor
databasejavascriptv0.4.4
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.

MySqlExtractor
const MySqlExtractor = require('mysql-extractor');
import MySqlExtractor from 'mysql-extractor';
CommonJS only; no ESM support.
MySqlExtractor
const MySqlExtractor = require('mysql-extractor');
Default export is a constructor. No named exports available.

Connects to a MySQL database, extracts schema info, and writes JSON files for tables, keys, indexes, and issues.

const MySqlExtractor = require('mysql-extractor'); const opts = { host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test', tableFile: 'tables.json', keyFile: 'keys.json', indexFile: 'indexes.json', issueFile: 'issues.json', issues: [ 'one_key_error', 'integer_primary_error', 'unsigned_primary_error', 'unique_primary_error', 'incrementing_primary_warning', 'id_primary_warning', 'reference_integer_foreign_error', 'reference_unsigned_foreign_error', 'reference_unique_foreign_error', 'integer_foreign_error', 'unsigned_foreign_error', 'index_foreign_warning', 'foreign_to_id_warning', 'reference_primary_foreign_warning', 'column_lowercase_warning' ], filterTableNames: function (tableNames) { return tableNames.filter(function (tableName) { return true; }); } }; const extractor = new MySqlExtractor(opts); extractor.createTableFile(); extractor.createForeignKeyFile(); extractor.createIndexFile(); extractor.createIssueFile();
Debug
Known issues
gotchaThe package uses an outdated 'mysql' driver which is deprecated and has no modern authentication support.
fix
Consider migrating to 'mysql2' for better security and features. The package itself may need to be forked or replaced.
affects: >=0.0.0
gotchaThe package does not support promise-based or async/await workflows; all methods are synchronous.
fix
Wrap calls in a synchronous context or use a different library that supports promises.
affects: >=0.0.0
gotchaNo TypeScript type definitions are provided.
fix
Create custom .d.ts or use // @ts-ignore.
affects: >=0.0.0
deprecatedThe npm 'mysql' driver is deprecated; the maintainer recommends using 'mysql2' instead.
fix
Replace dependency with 'mysql2' and adjust the connection options accordingly.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
The mysql driver is a peer dependency that must be manually installed.
fix
Run: npm install mysql
TypeError: MySqlExtractor is not a constructor
Using incorrect import: attempted named import instead of default require.
fix
Use: const MySqlExtractor = require('mysql-extractor');
Upgrade
Version history
0.4.4latest on npm
Audit
Dependencies
mysqlrequiredThe mysql npm package is required to connect to and query the MySQL database.
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-extractor — npm install mysql-extractor · libregistry