DEV Community

Sualeh Fatehi
Sualeh Fatehi

Posted on • Edited on

26 1 1 1 1

Automatically Document Your Database in Markdown

Use SchemaCrawler to generate Markdown documentation from your existing database. You can tweak the output to your heart's content using Python scripting. (SchemaCrawler also supports JavaScript and Ruby scripting.)

Try it out. Make sure that you have Docker installed on your system, or download SchemaCrawler. Download a sample SQLite database called "chinook-database-2.0.1.sqlite" into your current directory.

Grab the Python script of "markdown.py" from SchemaCrawler's GitHub repository, and save it in your local directory.

Then run a command like:

docker run \
--mount type=bind,source="$(pwd)",target=/home/schcrwlr/share \
--rm -it \
schemacrawler/schemacrawler \
/opt/schemacrawler/bin/schemacrawler.sh \
--server=sqlite \
--database=share/chinook-database-2.0.1.sqlite \
--info-level=standard \
--command script \
--script-language python \
--script share/markdown.py
Enter fullscreen mode Exit fullscreen mode

(If you are using PowerShell on Windows, replace the trailing backslash on each line with a back-tick "`".)

There is a simpler example of this in the scripting gist.

Once you have got this working, you can connect to any database - whether Oracle, MySQL, PostgreSQL, Microsoft SQL Server, IBM DB2 or any other database that SchemaCrawler supports.

You can build the Markdown generation in a GitHub Action or GitLab build too. An example is in the schemacrawler/SchemaCrawler-Action-Usage-Example repository.


To learn about how to use SchemaCrawler, download the SchemaCrawler distribution zip file and go through the examples.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay