DEV Community

Sualeh Fatehi
Sualeh Fatehi

Posted on • Updated on

How to Document Your Trino Database with One Command (and Nothing to Install)

Ever wondered what the tables in your Trino database look like? Generate a text file of your Trino database with one command. You can run this on any system that has Docker installed.

For now, create a Trino database in a Docker container. Later you can use the same technique to conect to your own Trino database. Create two Docker Compose files for the Trino and SchemaCrawler containers from the GitHub gist for this article.

Then open a command shell in the same folder that you created these files, and run:

docker-compose -f schemacrawler.yaml -f trino.yaml up -d
Enter fullscreen mode Exit fullscreen mode

Wait for a while for the containers to start up, connect into the SchemaCrawler container by running:

docker exec -it schemacrawler bash
Enter fullscreen mode Exit fullscreen mode

In the SchemaCrawler container shell, run SchemaCrawler against the Trino database to see your table. Run:

schemacrawler \
  --url jdbc:trino://trino:8080/ \
  --user test \
  --schemas tpch\.sf1 \
  --info-level minimum \
  --command list
Enter fullscreen mode Exit fullscreen mode

After you have got this working, you can alter the command to show more details of the database. For example, you can run:

schemacrawler \
  --url jdbc:trino://trino:8080/ \
  --user test \
  --schemas tpch\.sf1 \
  --info-level standard \
  --command schema
Enter fullscreen mode Exit fullscreen mode

You can save the output with an additional --output-file share/schema.txt argument, and the file will be created in your local directory. schemacrawler help will give you more information, as well as the SchemaCrawler website. Now you are ready to connect to your own database. If you need help on how to construct the connection URL, take a look at Trino JDBC Driver documentation.

Top comments (0)