{"id":14008203,"url":"https://github.com/erizocosmico/csvquery","last_synced_at":"2025-08-13T22:31:17.134Z","repository":{"id":57504145,"uuid":"140306442","full_name":"erizocosmico/csvquery","owner":"erizocosmico","description":"Query CSV files with SQL.","archived":false,"fork":false,"pushed_at":"2018-10-15T08:33:44.000Z","size":1823,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T07:21:23.471Z","etag":null,"topics":["csv","mysql","query","repl","server","sql"],"latest_commit_sha":null,"homepage":null,"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/erizocosmico.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":"2018-07-09T15:37:29.000Z","updated_at":"2023-08-24T05:24:46.000Z","dependencies_parsed_at":"2022-08-27T23:53:33.147Z","dependency_job_id":null,"html_url":"https://github.com/erizocosmico/csvquery","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/erizocosmico/csvquery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erizocosmico%2Fcsvquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erizocosmico%2Fcsvquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erizocosmico%2Fcsvquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erizocosmico%2Fcsvquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erizocosmico","download_url":"https://codeload.github.com/erizocosmico/csvquery/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erizocosmico%2Fcsvquery/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270328988,"owners_count":24565769,"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","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csv","mysql","query","repl","server","sql"],"created_at":"2024-08-10T11:01:24.913Z","updated_at":"2025-08-13T22:31:15.953Z","avatar_url":"https://github.com/erizocosmico.png","language":"Go","readme":"# csvquery [![Build Status](https://travis-ci.org/erizocosmico/csvquery.svg?branch=master)](https://travis-ci.org/erizocosmico/csvquery) [![codecov](https://codecov.io/gh/erizocosmico/csvquery/branch/master/graph/badge.svg)](https://codecov.io/gh/erizocosmico/csvquery) [![Go Report Card](https://goreportcard.com/badge/github.com/erizocosmico/csvquery)](https://goreportcard.com/report/github.com/erizocosmico/csvquery) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nQuery CSV files using SQL.\n\n## Features\n\n- Interactive REPL to quickly query CSV files with on demand file loading.\n- MySQL-compatible server to query CSV files, powered by [go-mysql-server](https://github.com/src-d/go-mysql-server).\n- Insertions of new rows (using `INSERT INTO`).\n\nFor more info about what subset of SQL is supported, check out the documentation of [go-mysql-server](https://github.com/src-d/go-mysql-server).\n\n## Install\n\nYou can install csvquery by downloading one of the prebuilt binaries available in the [releases page](https://github.com/erizocosmico/csvquery/releases).\n\nOr install it manually:\n\n```\ngo get github.com/erizocosmico/csvquery/...\n```\n\n## Usage\n\nThere are two way you can use csvquery: REPL or server.\n\n### REPL\n\nYou can start the REPL with the following command:\n\n```\ncsvquery repl\n```\n\nIf you want to add some CSV files as tables directly when you're starting the command, you can do so with the `-f` flag.\n\n```\ncsvquery repl -f some/file.csv -f another/file.csv:custom_table_name\n```\n\nAs you can see in the previous example, you can choose a custom name for the table with the syntax `FILE_PATH:TABLE_NAME`. If no custom name is provided, the table name will be the file name without the extension and with all characters that are not alphanumeric or underscore removed.\n\nIf you don't want to load the files on startup time, don't worry, you can load them later using `load`.\n\nOnce the REPL has started, you can use the following commands:\n\n- `load \u003cFILE_PATH\u003e[ \u003cTABLE_NAME\u003e]` to load a new file into the database with the given table name (or the default one if it's not provided).\n- `help` to show the usage.\n- `quit` or `exit` to exit the REPL.\n- `\u003cSQL QUERY\u003e` to execute a SQL query.\n\n### Server\n\nThe server, unlike the REPL, needs all tables loaded at the start of the command, so you must provide all the CSV files that you want to query as flags using the `-f` flag. You can see an example of how to do that in the [REPL](#REPL) section.\n\nThese are all available options for the server:\n\n```\n-d, --dbname=   Database name. (default: csv)\n-f, --file=     Add file as a table. You can use the flag in the format '/path/to/file:NAME' to give the file a\n                specific table name. Otherwise, the file name without extension will be the table name with only\n                alphanumeric characters and underscores.\n-u, --user=     User name to access the server. (default: root)\n-p, --password= Password to access the server.\n-P, --port=     Port in which the server will listen. (default: 3306)\n-h, --host=     Host name of the server. (default: 127.0.0.1)\n```\n\nFor example, let's start the server with the test data contained in the `_testdata` directory of this repository.\n\n```\ncsvquery server -f _testdata/ratings.csv -f _testdata/superheroes.csv\n```\n\nNow, let's connect to the server using the `mysql` client tool and execute a query:\n\n```\n$ mysql --host=127.0.0.1 --port=3306 -u root\nmysql\u003e SELECT COUNT(*) as num_ratings, id\n    -\u003e FROM superheroes s\n    -\u003e INNER JOIN ratings r ON s.id = r.superhero_id\n    -\u003e GROUP BY id;\n+-------------+------+\n| num_ratings | id   |\n+-------------+------+\n|           1 | sm   |\n|           2 | bm   |\n|           2 | ww   |\n|           2 | ma   |\n+-------------+------+\n4 rows in set (0.00 sec)\n```\n\n## Roadmap\n\n- [x] Read-only queries with REPL and server.\n- [x] Support insertions.\n- [ ] Support updates and deletes.\n- [ ] Support creating indexes.\n\n## LICENSE\n\nMIT License, see [LICENSE](/LICENSE).","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferizocosmico%2Fcsvquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferizocosmico%2Fcsvquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferizocosmico%2Fcsvquery/lists"}