tbls

repository·main·Indexed 26 days ago

https://github.com/k1low/tbls

A CI-friendly tool written in Go that automatically generates database documentation in GitHub Flavored Markdown (GFM). It supports a wide range of datasources including PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Cloud Spanner, Amazon Redshift, MS SQL Server, Amazon DynamoDB, Snowflake, MongoDB, ClickHouse, Databricks, JSON, HTTP, and GitHub. Beyond documentation, tbls can act as a linter to enforce schema standards, measure document coverage, and export schemas in formats such as DOT, PlantUML, Mermaid, JSON, YAML, and Excel.

Tokens
63.2K
Snippets
96
Records
347
Agent score
86%

What's inside tbls

  1. Overview of bigquery-public-data:census_bureau_international dataset

    main

    The bigquery-public-data:census_bureau_international dataset contains United States Census Bureau international estimates for country populations from 1950 to 2050. It includes midyear population figures (broken down by age and gender), fertility rates, birth rates, death rates, and migration rates.

    Dataset Details:

    • Source: United States Census Bureau
    • Update Frequency: Historic
    • Labels: dg_data_confidentiality:public, dg_data_context:metadata, dg_data_source:public, freebqcovid:freebqcovid
    • Terms of Use: Publicly available under data.gov privacy policy.
  2. View ClickHouse database documentation structure

    main

    The testdb sample documentation for ClickHouse organizes database metadata into three main categories:

    1. Tables: Detailed documentation for individual tables (e.g., source_table, materialized_view, t1) including columns, types, and comments.
    2. Stored procedures and functions: Documentation for database-level logic like linear_equation.
    3. Relations: An Entity-Relationship (ER) diagram provided as schema.svg to visualize table connections.
  3. View sample database documentation for relations

    main
    The sample/detect_relations directory contains a sample database documentation generated by tbls. It demonstrates how tbls documents various database objects including tables, views, stored procedures, functions, and their relationships (ER diagrams).
  4. View generated Spanner database documentation

    main

    When using tbls to document a Google Cloud Spanner database, the tool generates a structured documentation site. For a database located at projects/tbls-spanner-test/instances/test-instance/databases/testdb, the documentation includes:

    • Tables: Individual Markdown files for each table (e.g., users.md, posts.md) containing column details, types, and comments.
    • Relations: An ER diagram (typically schema.svg) visualizing the relationships between tables.

    Each table documentation file is linked from the main index page.

  5. View sample database documentation for testdb

    main
    The testdb sample database provides a reference for how tbls documents various database objects including tables, views, and relations. It demonstrates how different table types (BASE TABLE vs VIEW), comments, and labels (e.g., green, red, blue) are rendered in the generated documentation.
  6. Use the tbls CLI

    main

    tbls is a CI-friendly tool written in Go for documenting databases. It operates by dispatching commands to specialized sub-commands (e.g., tbls-mysql, tbls-postgres) found in your PATH.

    To use it, call tbls followed by the desired subcommand and any subcommand-specific arguments. You can provide global configuration via a config file or a DSN (Data Source Name).

  7. Explore the testdb sample database documentation

    main

    The testdb sample provides a structured overview of a database schema, organized by viewpoints, tables, stored procedures, and relations. It serves as a reference for how tbls documents database assets.

    Viewpoints

    Viewpoints allow you to group related database entities for specific contexts:

    • Content: Content as an asset for blogging services
    • Ops: Tables to be referenced during operation
    • Around the users table: Tables related to the users table
    • Secure data: Tables with secure data

    Tables

    The documentation includes various table types, such as BASE TABLE and VIEW, categorized by their purpose and labeled for easier filtering (e.g., content, user).

    Stored Procedures and Functions

    Functions and procedures are documented with their return types and arguments:

    • CustomerLevel (FUNCTION): Returns varchar, accepts credit decimal
    • GetAllComments (PROCEDURE)

    Relations

    Database relationships are visualized via an ER diagram (schema.svg).

  8. Understand the structure of viewpoint files

    main

    In tbls, a viewpoint file (e.g., viewpoint-2.md) is a generated documentation file that groups related database entities. It provides a high-level overview of a specific domain or functional area of the database, such as 'Around the users table'.

    Each viewpoint typically contains:

    • Description: A summary of the functional area.
    • Tables: A categorized list of tables, including their column counts, comments, types, and labels.
    • Relations: An ER diagram (usually as an SVG) visualizing the relationships between the tables in that viewpoint.
  9. View the testdb sample database documentation

    main

    The testdb sample provides a demonstration of documentation generated by tbls. It includes documentation for various database objects such as tables, views, stored procedures, functions, and relations.

    Key components documented in this sample include:

    • Tables: Examples of different naming conventions (e.g., CamelizeTable, hyphen-table, long_long_long_long_long_long_long_long_table_name) and table types (BASE TABLE, VIEW).
    • Stored Procedures and Functions: Documentation of arguments, return types, and procedure names.
    • Relations: An ER diagram (schema.png) representing the database schema.
  10. View documentation for bigquery-public-data:crypto_bitcoin

    main

    The bigquery-public-data:crypto_bitcoin dataset contains documentation for Bitcoin blockchain data exported via bitcoin-etl. The documentation includes details on tables, views, and their relationships.

    Tables and Views

    • blocks: Contains all blocks (13 columns). Type: TABLE.
    • inputs: Contains inputs from all transactions (14 columns). Type: VIEW.
    • outputs: Contains outputs from all transactions (11 columns). Type: VIEW.
    • transactions: Contains all transactions (34 columns). Type: TABLE.

    Relations

    Entity-relationship diagrams (ER diagrams) are available as schema.svg within the documentation directory.

  11. View the workspace.tpch_sf1 database documentation

    main

    The workspace.tpch_sf1 workspace contains documentation for a TPC-H scale factor 1 dataset. It includes detailed documentation for several managed tables and their relationships, visualized via an ER diagram (schema.svg).

    Tables

    NameColumnsCommentType
    customer8Customer information including demographics and account detailsMANAGED
    lineitem16Individual line items within orders, including pricing, shipping, and part detailsMANAGED
    nation4Countries/nations with their associated regionsMANAGED
    orders9Customer orders with status, pricing, and processing informationMANAGED
    part9Parts catalog with manufacturing and pricing informationMANAGED
    partsupp5Association of parts with suppliers including available quantity and costMANAGED
    region3Geographic regions containing nationsMANAGED
    supplier7Suppliers with contact and account informationMANAGED