tbls is a free, open source databases project written in Go and released under MIT. It has 4,344 GitHub stars, 210 forks and 55 open issues, and was last pushed 10 hours ago. On this registry it ranks #160 of 203 tracked projects in Databases, with 5 head-to-head comparisons available.

What is tbls?

tbls is an MIT-licensed, Go-written command line tool that automatically documents a database schema as Markdown and other formats, aimed at developers, data engineers, and platform teams who want schema documentation generated, diffed, and linted inside continuous integration instead of maintained by hand.

What it is

tbls (pronounced /ˈteɪbl̩z/) is a CI-friendly database documentation tool written in Go. It connects to a database through a DSN and generates a document set describing the schema, including tables, columns, comments, and relations, in GitHub Flavored Markdown and several other output formats. Configuration lives in a .tbls.yml or tbls.yml file inside the repository, where the datasource DSN and the output location are declared; docPath defaults to dbdoc.

The concrete problem it solves is that hand-written schema documentation drifts out of date as migrations land. tbls replaces manual upkeep of schema documents by generating them from the live database and then letting CI verify them: tbls diff compares a database against the existing document or against another database, tbls lint works as a linter for the database itself, and document coverage can be measured so missing table and column descriptions become visible. Because it ships as a single binary and is also distributed as a Docker image and a GitHub Action, the whole check fits into an ordinary pipeline in the Infrastructure & Operations / Databases space.

Key capabilities

  • Generate database documentation automatically in GFM format, with additional output formats including Markdown, Excel, and Mermaid and PlantUML ER diagrams.
  • Document many datasources: PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, BigQuery, Amazon DynamoDB, Amazon Redshift, Snowflake, and Google Cloud Spanner.
  • Diff a database against its documentation, or one database against another, using tbls diff.
  • Lint the database with tbls lint and measure document coverage.
  • Define relations, viewpoints, a dictionary, comments, labels, and table filters in .tbls.yml.
  • Personalize output with custom templates, expand environment variables in configuration, and require a specific version of tbls.
  • Run as a single binary, installed through Homebrew, MacPorts, a deb or RPM package, aqua, go install github.com/k1LoW/tbls@latest, or the ghcr.io/k1low/tbls Docker image.

Who uses it and how

  • Teams that keep schema documentation in the repository run tbls doc and commit the generated files under a docPath such as doc/schema.
  • CI pipelines run tbls doc on push to main through the k1low/setup-tbls@v1 Action, so the build surfaces documentation drift.
  • Docker users run docker run --rm -v $PWD:/work -w /work ghcr.io/k1low/tbls doc where installing Go or a system package is unwanted.
  • Organizations with several engines point one tool at PostgreSQL, MySQL, BigQuery, and Snowflake schemas instead of keeping per-engine scripts.

Getting started

Install with brew install tbls, a deb or RPM package, MacPorts, aqua, or go install github.com/k1LoW/tbls@latest, or pull ghcr.io/k1low/tbls:latest. Then add a .tbls.yml containing a dsn and run tbls doc postgres://dbuser:dbpass@hostname:5432/dbname.

How it compares

The facts provided name no other database documentation tool, so this page stands alone in this registry. On its own facts, the distinguishing property is the MIT licence combined with a single Go binary that doubles as documentation generator, differ, and linter rather than a hosted service.

When to use it — and when not to

tbls needs a reachable database: the DSN is supplied through .tbls.yml or the command line, so in CI the target database must run as a service with credentials available, which environment-variable expansion support eases but does not remove. A team that wants a hosted, always-on schema browser, or one that runs no CI at all, should not pick it. Note also that the project carries 55 open issues, so expect some rough edges around individual datasources.

project readme (upstream, from github) — read inline


tbls

Build Status GitHub release Go Report Card Coverage Code to Test Ratio Test Execution Time

tbls (pronounced /ˈteɪbl̩z/) is a CI-Friendly tool to document a database, written in Go.

Key features of tbls are:

Table of Contents


Quick Start

Document a database with one command.

$ tbls doc postgres://dbuser:dbpass@hostname:5432/dbname

Using docker image.

$ docker run --rm -v $PWD:/work -w /work ghcr.io/k1low/tbls doc postgres://dbuser:dbpass@hostname:5432/dbname

Install

deb:

$ export TBLS_VERSION=X.X.X
$ curl -o tbls.deb -L https://github.com/k1LoW/tbls/releases/download/v$TBLS_VERSION/tbls_$TBLS_VERSION-1_amd64.deb
$ dpkg -i tbls.deb

RPM:

$ export TBLS_VERSION=X.X.X
$ yum install https://github.com/k1LoW/tbls/releases/download/v$TBLS_VERSION/tbls_$TBLS_VERSION-1_amd64.rpm

Homebrew:

$ brew install tbls

MacPorts:

$ sudo port install tbls

aqua:

$ aqua g -i k1LoW/tbls

Manually:

Download binary from releases page

go install:

$ go install github.com/k1LoW/tbls@latest

Docker:

$ docker pull ghcr.io/k1low/tbls:latest

On GitHub Actions:

# .github/workflows/doc.yml
name: Document

on:
  push:
    branches:
      - main

jobs:
  doc:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout .tbls.yml
        uses: actions/checkout@v3
      -
        uses: k1low/setup-tbls@v1
      -
        name: Run tbls for generate database document
        run: tbls doc

:octocat: A GitHub Action for tbls is here.

Temporary:

$ source <(curl https://raw.githubusercontent.com/k1LoW/tbls/main/use)
$ curl -sL https://raw.githubusercontent.com/k1LoW/tbls/main/use > /tmp/use-tbls.tmp && . /tmp/use-tbls.tmp

Getting Started

Document a database

Add .tbls.yml (or tbls.yml) file to your repository.

# .tbls.yml

# DSN (Database Source Name) to connect database
dsn: postgres://dbuser:dbpass@localhost:5432/dbname

# Path to generate document
# Default is `dbdoc`
docPath: doc/schema

Notice: If you are using a symbol such as # **Notice:**tbls diff` shows the difference Markdown documents only.

Re-generating database documentation

Existing documentation can re-generated using either --force or --rm-dist flag.

--force forces overwrite of the existing documents. It does not, however, remove files of removed tables.

$ tbls doc --force

--rm-dist removes files in docPath before generating the documents.

$ tbls doc --rm-dist

Lint a database

Add linting rule to .tbls.yml following

# .tbls.yml
lint:
  requireColumnComment:
    enabled: true
    exclude:
      - id
      - created
      - updated
  columnCount:
    enabled: true
    max: 10

Run tbls lint to check the database according to lint: rules

$ tbls lint
users.username: column comment required.
users.password: column comment required.
users.phone_number: column comment required.
posts.user_id: column comment required.
posts.title: column comment required.
posts.labels: column comment required.
comments.post_id: column comment required.
comment_stars.user_id: column comment required.
post_comments.comment: column comment required.
posts: too many columns. [12/10]
comments: too many columns. [11/10]

11 detected

Measure document coverage

tbls coverage measure and show document coverage (description, comments).

$ tbls coverage
Table                       Coverage
All tables                  16.1%
 public.users               20%
 public.user_options        37.5%
 public.posts               35.3%
 public.comments            14.3%
 public.comment_stars       0%
 public.logs                12.5%
 public.post_comments       87.5%
 public.post_comment_stars  0%
 public.CamelizeTable       0%
 public.hyphen-table        0%
 administrator.blogs        0%
 backup.blogs               0%
 backup.blog_options        0%
 time.bar                   0%
 time.hyphenated-table      0%
 time.referencing           0%

Continuous Integration

Continuous integration using tbls.

  1. Commit the document using tbls doc.
  2. Update the database schema in the development cycle.
  3. Check for document updates by running tbls diff or tbls lint in CI.
  4. Return to 1.

Example: Travis CI

# .travis.yml
language: go

install:
  - source <(curl -sL https://raw.githubusercontent.com/k1LoW/tbls/main/use)
script:
  - tbls diff
  - tbls lint

Tips: If your CI based on Debian/Ubuntu (/bin/sh -> dash), you can use the following install command `curl -sL https://raw.githubusercont

readme truncated — read the full docs on github

Frequently asked questions

Is tbls free to use?

tbls is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does tbls do?

tbls is a CI-Friendly tool to document a database, written in Go.

What is tbls written in?

tbls is primarily written in Go. Its source is publicly available at https://github.com/k1LoW/tbls, and it has 4,344 GitHub stars.