Converting MySQL Schema to GitHub Wiki
Problem:
You want to export a MySQL database schema into a markdown format suitable for GitHub Wiki pages.
Solution:
Here is a custom solution using two MySQL stored procedures to convert the database schema into a markdown table format:
Stored Procedures:
-- Stored Procedure 1: describeTables_v2a CREATE PROCEDURE `Reporting101a`.`describeTables_v2a`( IN dbName varchar(100), -- The database name to report table structures OUT theSession int, -- OUT parameter for session# assigned IN deleteSessionRows BOOL, -- True for deleting rows when done from main reporting table for this session# IN callTheSecondStoredProc BOOL -- TRUE = output is from Pretty output in Second Stored Proc. FALSE = not so pretty output ) BEGIN -- Code goes here... END$$ -- Stored Procedure 2: Print_Tables_Like_Describe CREATE PROCEDURE `Reporting101a`.`Print_Tables_Like_Describe`( pSessionId INT ) BEGIN -- Code goes here... END$$
Usage:
Output:
The output will be a table-formatted markdown file containing the structure of all tables in the specified database. The output format is similar to MySQL's DESCRIBE command.
Additional Notes:
The above is the detailed content of How Can I Convert a MySQL Schema to a GitHub Wiki-Friendly Markdown Table?. For more information, please follow other related articles on the PHP Chinese website!