Converting MySQL Schema to GitHub Wiki Markdown
The original issue raised concerns about exporting a MySQL database schema into Markdown format, specifically as tables. To address this, a detailed response provides a solution involving the use of two stored procedures.
First Stored Procedure: describeTables_v2a
This procedure takes a database name as input and generates an output that resembles the output of DESCRIBE myTable for all tables in that database. It achieves this by utilizing the INFORMATION_SCHEMA database and manipulating the results to provide a more detailed and organized output. The output is stored in the reportDataDefs table of the Reporting101a database.
Parameters:
Steps:
Second Stored Procedure: Print_Tables_Like_Describe
This procedure takes a session number as input and retrieves the data from the reportDataDefs table. It then generates a Markdown-formatted output that resembles the DESCRIBE myTable output but for every table in the specified database.
Steps:
Usage:
To use the stored procedures, the user can provide the required database name and other parameters. Here's an example of the usage:
SET @theOutVar =-1; -- A variable used as the OUT variable below -- Note: with `TRUE` as the 4th parameter, this is a one call deal. Meaning, you are done. call Reporting101a.describeTables_v2a('stackoverflow',@theOutVar,false,true); -- Primarily used if the 4th parameter above is false call Reporting101a.Print_Tables_Like_Describe(@theOutVar); -- loads data for prettier results in chunk format.
This usage would first call the Reporting101a.describeTables_v2a stored procedure and retrieve the session number. Then, it would automatically call the Reporting101a.Print_Tables_Like_Describe stored procedure with that session number to generate the pretty-printed output. The output would be returned as a result set, which can be consumed and formatted further, such as converting it to a Markdown-formatted table.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3