Export MySQL database schemas to JSON format, including table relationships. Version 1.2.0. This library extracts table structure, fields, and foreign key relations from a MySQL database and outputs them as JSON. It also supports heuristic discovery of relationships by field naming conventions (prefix/suffix aliases). It provides both synchronous and asynchronous connection methods, as well as granular functions for fetching schemas, table lists, fields, and relations. Suitable for documentation generation or migration tasks.
npm install mysql-json-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates exporting a full schema to a single JSON file and using individual methods to retrieve a schema object.
Update code to expect { tables: [...], relations: [...] } instead of just an array.Use CreateConnectionAsync and await or .then() to get the connection.
Always call connection.end() after using synchronous methods, or use async methods with proper error handling.
Ensure the outputFolder exists before calling ExportSchemaToFile or ExportSchemaToFiles.
Use require('mysql-json-schema') or import { CreateConnection } from 'mysql-json-schema'.Run 'npm install mysql' alongside mysql-json-schema.
Double-check the user, password, host, and database name in the connection arguments.
Ensure CreateConnection or CreateConnectionAsync returns a valid connection object before calling schema methods.