{"id":13621537,"url":"https://github.com/akarki15/dbdot","last_synced_at":"2025-04-15T01:33:03.235Z","repository":{"id":39459819,"uuid":"179895827","full_name":"akarki15/dbdot","owner":"akarki15","description":"Generate DOT description for postgres db schema","archived":false,"fork":false,"pushed_at":"2020-05-24T22:41:48.000Z","size":253,"stargazers_count":403,"open_issues_count":9,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-01T21:48:03.882Z","etag":null,"topics":["graph-description-language","postgresql","schema"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akarki15.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-06T23:00:20.000Z","updated_at":"2024-07-12T13:18:28.000Z","dependencies_parsed_at":"2022-09-15T10:50:18.613Z","dependency_job_id":null,"html_url":"https://github.com/akarki15/dbdot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarki15%2Fdbdot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarki15%2Fdbdot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarki15%2Fdbdot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarki15%2Fdbdot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akarki15","download_url":"https://codeload.github.com/akarki15/dbdot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223654764,"owners_count":17180586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-description-language","postgresql","schema"],"created_at":"2024-08-01T21:01:07.661Z","updated_at":"2024-11-08T08:31:04.673Z","avatar_url":"https://github.com/akarki15.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# dbdot\n\n`dbdot` is a command line tool that generates [DOT](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) description from postgres database schema.\n\n`dbdot` is compiled to platform specific binary, so all you need is the right binary for your machine. Grab the appropriate binary for your architecture from the [latest release here](https://github.com/akarki15/dbdot/releases).\n\n# Demos\n#### Demo 1: Produce DOT for all the tables in postgres db `pgguide` and user `kewluser`\n```\n$ ./dbdot -dbname=pgguide -user=kewluser                                                                                                       [16:33:31]\ndigraph  {\n\n\tnode[label=\u003c\u003cTABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"\u003e\u003cTR\u003e\u003cTD colspan=\"2\"\u003eproducts\u003c/TD\u003e\u003c/TR\u003e[\u003cTR\u003e\u003cTD\u003eid\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003etitle\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003eprice\u003c/TD\u003e\u003cTD\u003enumeric\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003ecreated_at\u003c/TD\u003e\u003cTD\u003etimestamp with time zone\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003edeleted_at\u003c/TD\u003e\u003cTD\u003etimestamp with time zone\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003etags\u003c/TD\u003e\u003cTD\u003eARRAY\u003c/TD\u003e\u003c/TR\u003e]\u003c/TABLE\u003e\u003e,shape=plaintext] n1;\n\tnode[label=\u003c\u003cTABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"\u003e\u003cTR\u003e\u003cTD colspan=\"2\"\u003epurchase_items\u003c/TD\u003e\u003c/TR\u003e[\u003cTR\u003e\u003cTD\u003eid\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003epurchase_id\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003eproduct_id\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003eprice\u003c/TD\u003e\u003cTD\u003enumeric\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003equantity\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003estate\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e]\u003c/TABLE\u003e\u003e,shape=plaintext] n2;\n\tnode[label=\u003c\u003cTABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"\u003e\u003cTR\u003e\u003cTD colspan=\"2\"\u003eusers\u003c/TD\u003e\u003c/TR\u003e[\u003cTR\u003e\u003cTD\u003eid\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003eemail\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003epassword\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003edetails\u003c/TD\u003e\u003cTD\u003eUSER-DEFINED\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003ecreated_at\u003c/TD\u003e\u003cTD\u003etimestamp with time zone\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003edeleted_at\u003c/TD\u003e\u003cTD\u003etimestamp with time zone\u003c/TD\u003e\u003c/TR\u003e]\u003c/TABLE\u003e\u003e,shape=plaintext] n3;\n\tnode[label=\u003c\u003cTABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"\u003e\u003cTR\u003e\u003cTD colspan=\"2\"\u003epurchases\u003c/TD\u003e\u003c/TR\u003e[\u003cTR\u003e\u003cTD\u003eid\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003ecreated_at\u003c/TD\u003e\u003cTD\u003etimestamp with time zone\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003ename\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003eaddress\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003estate\u003c/TD\u003e\u003cTD\u003echaracter varying\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003ezipcode\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e \u003cTR\u003e\u003cTD\u003euser_id\u003c/TD\u003e\u003cTD\u003einteger\u003c/TD\u003e\u003c/TR\u003e]\u003c/TABLE\u003e\u003e,shape=plaintext] n4;\n\tn2-\u003en1;\n\tn2-\u003en4;\n\tn4-\u003en3;\n\n}\n```\n#### Demo 2: Produce a schema diagram for all the tables in `pgguide` db for `kewluser`\n```\n$ ./dbdot -dbname=pgguide -user=kewluser \u003e test.dot \u0026\u0026 dot -Tpng test.dot -o outfile.png \u0026\u0026 open outfile.png\n```\nAbove command pipes the DOT description into test.dot and invokes `dot` cli tool to transform test.dot to a outfile.png. Here's what outfile.png looks like:\n\n![outfile.png](https://raw.githubusercontent.com/akarki15/dbdot/master/images/outfile.png)\n\n#### Demo 3: Whitelist tables and produce schema diagram for them\n```\n./dbdot -dbname=pgguide -user=kewluser \u003e test.dot --whitelist=purchase_items,purchases \u0026\u0026 dot -Tpng test.dot -o outfile-whitelisted.png \u0026\u0026 open outfile-whitelisted.png\n```\nHere's what outfile-whitelisted.png looks like:\n\n![outfile-whitelisted.png](https://raw.githubusercontent.com/akarki15/dbdot/master/images/outfile-whitelisted.png)\n\n# Flags\ndbdot currently supports the following flags:\n```\n  -W    ask for password\n  -dbname string\n        dbname for which you want to generate dot file\n  -host string\n        database host (default \"localhost\")\n  -port uint\n        database port (default 5432)\n  -schema string\n        schema name (default \"public\")\n  -sslmode\n        enable sslmode for postgres db connection\n  -user string\n        username of postgres db\n  -whitelist string\n        comma separated list of tables you want to generate dot file for\n```\n\n# TODO\nHere's some features I would like to have for this project:\n* Support connection string. What happens if the user doesn't have access to db?\n* Add support for more db types.\n* Prettify output.\n* Add ability to whitelist columns in a table. Users should be able whitelist columns per table. But this starts getting into territory of language design. i.e. what kind of cli syntax should dbdot support. Hence this is the last item in my list.\n\n# Inspiration\nA while back I wanted a _simple_ tool that would just spit out schema for tables that I wanted. A lot of tools I found were way too powerful, requiring a zillion installation and configuration. This inspired me to write a simple self contained tool that was laser focused on just reading schema and spitting out DOT.\n\n# Similar projects\n* http://schemaspy.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakarki15%2Fdbdot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakarki15%2Fdbdot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakarki15%2Fdbdot/lists"}