{"id":15056789,"url":"https://github.com/tenmax/cqlkit","last_synced_at":"2025-08-21T08:30:56.324Z","repository":{"id":57634680,"uuid":"39863761","full_name":"tenmax/cqlkit","owner":"tenmax","description":"CLI tool to export Cassandra query as CSV and JSON format.","archived":false,"fork":false,"pushed_at":"2020-07-06T07:16:03.000Z","size":254,"stargazers_count":106,"open_issues_count":2,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-27T00:49:05.903Z","etag":null,"topics":["cassandra","cli"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tenmax.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":"2015-07-29T00:02:18.000Z","updated_at":"2025-01-10T11:15:21.000Z","dependencies_parsed_at":"2022-09-17T04:25:35.177Z","dependency_job_id":null,"html_url":"https://github.com/tenmax/cqlkit","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/tenmax/cqlkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenmax%2Fcqlkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenmax%2Fcqlkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenmax%2Fcqlkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenmax%2Fcqlkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tenmax","download_url":"https://codeload.github.com/tenmax/cqlkit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenmax%2Fcqlkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271449095,"owners_count":24761602,"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-21T02:00:08.990Z","response_time":74,"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":["cassandra","cli"],"created_at":"2024-09-24T21:56:30.252Z","updated_at":"2025-08-21T08:30:55.996Z","avatar_url":"https://github.com/tenmax.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CQLKIT\n*cqlkit* is a CLI tool to export Cassandra query to CSV and JSON format. Cassandra is not good at Ad-hoc query, *cqlkit* allows you to export query result to semi-structured(JSON) or structured data(CSV). There are many [tools](#recommended-3rd-party-tools) out there for you to query or process these kinds of format.\n\nHere is a simple some examples.\n\nExport JSON for the system columns in cassandra cluster.\n \n```bash\ncql2json -q \"select peer, data_center, host_id, preferred_ip, rack, release_version from system.peers\"\n```\n\nExport CSV for the system columns in cassandra cluster.\n\n```bash\ncql2csv -q \"select peer, data_center, host_id, preferred_ip, rack, release_version from system.peers\"\n```\n\n# Requirement\n\n- Java8\n\n# Installation\n\n## General\n\n1. Download from [release](https://github.com/tenmax/cqlkit/releases) page.\n2. Unzip the package.\n3. Add `$CQLKIT_PATH/bin` to the *PATH* environment variable\n\n## Mac\n\nInstall cqlkit via [Homebrew](http://brew.sh/).\n\n```bash\nbrew update\nbrew install cqlkit\n```\n\nUpgrade cqlkit\n\n```bash\nbrew update\nbrew upgrade cqlkit\n```\n\n## Docker\n\nRun cqlkit via [Docker](https://hub.docker.com/r/tenmax/cqlkit).\n\n```bash\n docker run --rm -it tenmax/cqlkit\n ```\n\n# Usage\n## CQL2CSV\n\n```\nusage: cql2csv [-c contactpoint] [-r cassandraPort] [-q query] [FILE]\nFile       The file to use as CQL query. If both FILE and QUERY are\n           omitted, query will be read from STDIN.\n\n -c \u003carg\u003e                            The contact point. if use multi\n                                     contact points, use ',' to separate\n                                     multi points\n    --connect-timeout \u003carg\u003e          Connection timeout in seconds;\n                                     default: 5\n    --consistency \u003cLEVEL\u003e            The consistency level. The level\n                                     should be 'any', 'one', 'two',\n                                     'three', 'quorum', 'all',\n                                     'local_quorum', 'each_quorum',\n                                     'serial' or 'local_serial'.\n    --cqlshrc \u003carg\u003e                  Use an alternative cqlshrc file\n                                     location, path.\n    --date-format \u003carg\u003e              Use a custom date format. Default is\n                                     \"yyyy-MM-dd'T'HH:mm:ss.SSSZ\"\n    --fetchSize \u003cSIZE\u003e               The fetch size. Default is 5000\n -h,--help                           Show the help and exit\n -H,--no-header-row                  Do not output column names.\n -k \u003carg\u003e                            The keyspace to use.\n -l,--linenumbers                    Insert a column of line numbers at\n                                     the front of the output. Useful when\n                                     piping to grep or as a simple primary\n                                     key.\n -p \u003carg\u003e                            The password to authenticate.\n -r \u003carg\u003e                            The port to connect to Cassandra, defaults to 9042.\n -P,--parallel \u003carg\u003e                 The level of parallelism to run the\n                                     task. Default is sequential.\n -q,--query \u003cCQL\u003e                    The CQL query to execute. If\n                                     specified, it overrides FILE and\n                                     STDIN.\n    --query-partition-keys \u003cTABLE\u003e   Query the partition key(s) for a\n                                     column family.\n    --query-ranges \u003cCQL\u003e             The CQL query would be splitted by\n                                     the token ranges. WHERE clause is not\n                                     allowed in the CQL query\n    --request-timeout \u003carg\u003e          Request timeout in seconds; default:\n                                     12\n -u \u003carg\u003e                            The user to authenticate.\n -v,--version                        Print the version\n```\n\n\n\n## CQL2JSON\n```\nusage: cql2json [-c contactpoint] [-r cassandraPort] [-q query] [FILE]\nFile       The file to use as CQL query. If both FILE and QUERY are\n           omitted, query will be read from STDIN.\n\n -c \u003carg\u003e                            The contact point. if use multi\n                                     contact points, use ',' to separate\n                                     multi points\n    --connect-timeout \u003carg\u003e          Connection timeout in seconds;\n                                     default: 5\n    --consistency \u003cLEVEL\u003e            The consistency level. The level\n                                     should be 'any', 'one', 'two',\n                                     'three', 'quorum', 'all',\n                                     'local_quorum', 'each_quorum',\n                                     'serial' or 'local_serial'.\n    --cqlshrc \u003carg\u003e                  Use an alternative cqlshrc file\n                                     location, path.\n    --date-format \u003carg\u003e              Use a custom date format. Default is\n                                     \"yyyy-MM-dd'T'HH:mm:ss.SSSZ\"\n    --fetchSize \u003cSIZE\u003e               The fetch size. Default is 5000\n -h,--help                           Show the help and exit\n -j,--json-columns \u003carg\u003e             The columns that contains json\n                                     string. The content would be used as\n                                     json object instead of plain text.\n                                     Columns are separated by comma.\n -k \u003carg\u003e                            The keyspace to use.\n -l,--linenumbers                    Insert a column of line numbers at\n                                     the front of the output. Useful when\n                                     piping to grep or as a simple primary\n                                     key.\n -p \u003carg\u003e                            The password to authenticate.\n -r \u003carg\u003e                            The port to connect to Cassandra, defaults to 9042.\n -P,--parallel \u003carg\u003e                 The level of parallelism to run the\n                                     task. Default is sequential.\n -q,--query \u003cCQL\u003e                    The CQL query to execute. If\n                                     specified, it overrides FILE and\n                                     STDIN.\n    --query-partition-keys \u003cTABLE\u003e   Query the partition key(s) for a\n                                     column family.\n    --query-ranges \u003cCQL\u003e             The CQL query would be splitted by\n                                     the token ranges. WHERE clause is not\n                                     allowed in the CQL query\n    --request-timeout \u003carg\u003e          Request timeout in seconds; default:\n                                     12\n -u \u003carg\u003e                            The user to authenticate.\n -v,--version                        Print the version\n```\n\n# cqlsh\n## Setup the cqlshrc\nTo connect to cassandra cluster, although we can use `-c` and `-k` to specify the contact server and keyspace respectively, to preapre a [cqlshrc](http://docs.datastax.com/en/cql/3.1/cql/cql_reference/cqlsh.html#refCqlsh__cqlshUsingCqlshrc) is recommended to simply your query. *cqlshrc* is used by cqlsh. *cqlkit* leverages this file to connect to your cluster. Here is the setup steps.\n\n1. Create the cqlshrc file at `~/.cassandra/cqlshrc`\n2. Here is the example format.\n\n   ```bash\n   [authentication]\n   keyspace = system\n\n   [connection]\n   hostname = 192.168.59.103\n   port = 9042\n\n   ; vim: set ft=dosini :\n   ```\n\n## Import data from a CSV file\n\n```\n$ cql2csv -q \"select text_col from ks.tbl\" \u003e example.csv\n\n$ ./cqlsh localhost\ncqlsh\u003e COPY ks.tbl FROM 'example.csv' WITH ESCAPE='\"' AND HEADER=TRUE\n```\n\n# Recommended 3rd Party Tools\n\n- [csvkit](https://csvkit.readthedocs.org/en/0.9.1/) - A toolkit to handle CSV files. There are many useful CLI tools included. \n\n- [q](https://github.com/harelba/q) - Another CSV tool which focuses on query on CSV files.\n\n- [json2csv](https://github.com/jehiah/json2csv) - Convert JSON format to CSV format\n\n- [jq](http://stedolan.github.io/jq/) - a lightweight and flexible command-line JSON processor.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenmax%2Fcqlkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftenmax%2Fcqlkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenmax%2Fcqlkit/lists"}