Home >Database >Mysql Tutorial >How to Convert a MySQL Schema to GitHub Wiki Markdown Using Stored Procedures?
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.
The above is the detailed content of How to Convert a MySQL Schema to GitHub Wiki Markdown Using Stored Procedures?. For more information, please follow other related articles on the PHP Chinese website!