{"id":15677784,"url":"https://github.com/noborus/mdtsql","last_synced_at":"2025-05-07T01:43:25.835Z","repository":{"id":57575221,"uuid":"233369316","full_name":"noborus/mdtsql","owner":"noborus","description":"Execute SQL to markdown table and convert to other format","archived":false,"fork":false,"pushed_at":"2025-01-16T12:06:27.000Z","size":523,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T05:03:33.477Z","etag":null,"topics":["markdown","md2csv","sql","trdsql"],"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/noborus.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-12T09:42:00.000Z","updated_at":"2025-01-16T12:06:29.000Z","dependencies_parsed_at":"2022-09-26T19:01:54.011Z","dependency_job_id":"51bb70e3-4e14-4905-b27c-579ff584dd27","html_url":"https://github.com/noborus/mdtsql","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fmdtsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fmdtsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fmdtsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noborus%2Fmdtsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noborus","download_url":"https://codeload.github.com/noborus/mdtsql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252798505,"owners_count":21805876,"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":["markdown","md2csv","sql","trdsql"],"created_at":"2024-10-03T16:11:45.857Z","updated_at":"2025-05-07T01:43:25.814Z","avatar_url":"https://github.com/noborus.png","language":"Go","readme":"# mdtsql\n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/noborus/mdtsql)](https://pkg.go.dev/github.com/noborus/mdtsql)\n[![Actions Status](https://github.com/noborus/mdtsql/workflows/Go/badge.svg)](https://github.com/noborus/mdtsql/actions)\n\nA CLI tool that executes SQL queries on various files including markdown table files and outputs the results to various files.\n\n## install\n\n### Go install\n\n```console\ngo install github.com/noborus/mdtsql/cmd/mdtsql@latest\n```\n\n### Homebrew\n\n```console\nbrew install noborus/tap/mdtsql\n```\n\n## Usage\n\nExecutes SQL for markdown containing table.\nThe result can be output to CSV, JSON, LTSV, YAML, Markdown, etc.\n\n```sh\nmdtsql query \"SELECT * FROM file.md\"\n```\n\n```sh\nmdtsql table file.md\n```\n\n### option\n\n```console\nmdtsql --help\nExecute SQL for table in markdown.\nThe result can be output to CSV, JSON, LTSV, YAML, Markdown, etc.\n\nUsage:\n  mdtsql [flags]\n  mdtsql [command]\n\nAvailable Commands:\n  completion  Generate the autocompletion script for the specified shell\n  help        Help about any command\n  list        List and analyze SQL dumps\n  query       Execute SQL queries on markdown table and tabular data\n  table       SQL(SELECT * FROM table) for markdown table and tabular data\n\nFlags:\n  -d, --Delimiter string   output delimiter (CSV only) (default \",\")\n  -O, --Header             output header (CSV only)\n  -o, --OutFormat string   output format=at|csv|ltsv|json|jsonl|tbln|raw|md|vf|yaml (default \"md\")\n  -c, --caption            caption table name\n      --config string      config file (default is $HOME/.mdtsql.yaml)\n      --debug              debug print\n  -h, --help               help for mdtsql\n  -v, --version            display version information\n\nUse \"mdtsql [command] --help\" for more information about a command.\n```\n\n### Example\n\n```sh\nmdtsql query \"SELECT * FROM file.md\"\n```\n\n| c1 | a  | b  | c  |\n|----|----|----|----|\n|  1 | a1 | b1 | c1 |\n|  2 | a2 | b2 | c2 |\n|  3 | a3 | b3 | c3 |\n\nIf the markdown includes multiple tables,\nthe second and subsequent tables are marked with `::number`.\n\n```sh\nmdtsql query \"SELECT * FROM file.md::1\"\n```\n\nSpecify the output format with option -o.\n-o csv, -o ltsv, -ojson ...\n\n```sh\nmdtsql -o csv query \"SELECT * FROM file.md\"\n```\n\n```CSV\n1,a1,b1,c1\n2,a2,b2,c2\n3,a3,b3,c3\n```\n\n### List Command\n\nThe `list` command displays all the tables in the specified markdown file.\n\n```sh\nmdtsql list file.md\n```\n\n```sh\nmdtsql list abc.md\nTable Name: [0]\n+-------------+------+\n| column name | type |\n+-------------+------+\n| c1          | text |\n| a           | text |\n| b           | text |\n| c           | text |\n+-------------+------+\n\nTable Name: [1]\n+-------------+------+\n| column name | type |\n+-------------+------+\n| c1          | text |\n| a           | text |\n| b           | text |\n| c           | text |\n+-------------+------+\n\nTable Name: [2]\n+-------------+------+\n| column name | type |\n+-------------+------+\n| c1          | text |\n| a           | text |\n| b           | text |\n| c           | text |\n+-------------+------+\n```\n\n## Table Command\n\nThe `table` command executes SQL(SELECT * FROM table) for markdown table and tabular data.\n\n```sh\nmdtsql table file.md\n```\n\n```sh\nmdtsql table file.md::1\n```\n\n## Caption option\n\nThe  `--caption` or `-c` option specifies a caption name, not a sequential number.\nThis allows you to specify the same table even if the order changes.\n\n```sh\nmdtsql --caption list testdata/abc.md\nTable Name: [header]\n+-------------+------+\n| column name | type |\n+-------------+------+\n| c1          | text |\n| a           | text |\n| b           | text |\n| c           | text |\n+-------------+------+\n\nTable Name: [caption]\n+-------------+------+\n| column name | type |\n+-------------+------+\n| c1          | text |\n| a           | text |\n| b           | text |\n| c           | text |\n+-------------+------+\n\nTable Name: [caption_1]\n+-------------+------+\n| column name | type |\n+-------------+------+\n| c1          | text |\n| a           | text |\n| b           | text |\n| c           | text |\n+-------------+------+\n```\n\n```sh\nmdtsql --caption query \"SELECT * FROM testdata/abc.md::caption_1\"\n| c1 | a  | b  | c  |\n|----|----|----|----|\n|  1 | a1 | b1 | c1 |\n|  2 | a2 | b2 | c2 |\n|  3 | a3 | b3 | c3 |\n```\n\n## Multiple queries\n\nYou can specify multiple queries with the `;` separator.\n\n```console\nmdtsql query \"INSERT INTO abc.md::2 (c1, a, b, c) VALUES ('4', 'a4', 'b4', 'c4');SELECT * FROM abc.md::2\"\n```\n\n| c1 | a  | b  | c  |\n|----|----|----|----|\n|  1 | a1 | b1 | c1 |\n|  2 | a2 | b2 | c2 |\n|  3 | a3 | b3 | c3 |\n| **4** | **a4** | **b4** | **c4** |\n\n```console\nmdtsql query \"UPDATE abc.md::2 SET c='u4' WHERE c1=3;SELECT * FROM abc.md::2\"\n```\n\n| c1 | a  | b  | c  |\n|----|----|----|----|\n|  1 | a1 | b1 | c1 |\n|  2 | a2 | b2 | c2 |\n|  3 | a3 | b3 | **u4** |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoborus%2Fmdtsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoborus%2Fmdtsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoborus%2Fmdtsql/lists"}