All Projects → tenmax → Cqlkit

tenmax / Cqlkit

Licence: apache-2.0
CLI tool to export Cassandra query as CSV and JSON format.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Cqlkit

Fvm
Flutter Version Management: A simple CLI to manage Flutter SDK versions.
Stars: ✭ 1,293 (+1275.53%)
Mutual labels:  cli
Aws Cli Cheatsheet
☁️ AWS CLI + JQ = Make life easier
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Centerline
Calculate the polygon's centerline
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Angular Librarian
An Angular 2+ scaffolding setup for creating libraries
Stars: ✭ 92 (-2.13%)
Mutual labels:  cli
Eazydict
简单易用的命令行词典 📕 📙 📗 📘 📓
Stars: ✭ 92 (-2.13%)
Mutual labels:  cli
Lab
lab is a cli client of gitlab like hub
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Restbase
Distributed storage with REST API & dispatcher for backend services.
Stars: ✭ 91 (-3.19%)
Mutual labels:  cassandra
Synonym
Find synonyms in 15 different languages directly from your terminal.
Stars: ✭ 95 (+1.06%)
Mutual labels:  cli
Matrix Commander
simple but convenient CLI-based Matrix client app for sending and receiving
Stars: ✭ 90 (-4.26%)
Mutual labels:  cli
Proxmove
Migrate virtual machines between different Proxmox VE clusters
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Awesome Git Addons
😎 A curated list of add-ons that extend/enhance the git CLI.
Stars: ✭ 1,313 (+1296.81%)
Mutual labels:  cli
Lc
licensechecker (lc) a command line application which scans directories and identifies what software license things are under producing reports as either SPDX, CSV, JSON, XLSX or CLI Tabular output. Dual-licensed under MIT or the UNLICENSE.
Stars: ✭ 93 (-1.06%)
Mutual labels:  cli
Getnews.tech
A web server that fetches data from the News API and formats it for display in the terminal.
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Krs
A command line tool for capturing and serializing Kubernetes resource statistics in OpenMetrics format
Stars: ✭ 92 (-2.13%)
Mutual labels:  cli
Gay
Colour your text / terminal to be more gay. 🏳️‍🌈
Stars: ✭ 95 (+1.06%)
Mutual labels:  cli
Jutil
Command-line utilities for manipulating JSON
Stars: ✭ 91 (-3.19%)
Mutual labels:  cli
Cli
A tiny CLI for HedgeDoc
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Generator Ngx Rocket
🚀 Extensible Angular 11+ enterprise-grade project generator
Stars: ✭ 1,329 (+1313.83%)
Mutual labels:  cli
Gophie
An Aggregator Engine for searching and downloading movies free - NO ADs!
Stars: ✭ 94 (+0%)
Mutual labels:  cli
Swagger Merger
🔗 Merge multiple swagger files into a swagger file, support JSON/YAML.
Stars: ✭ 94 (+0%)
Mutual labels:  cli

CQLKIT

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 out there for you to query or process these kinds of format.

Here is a simple some examples.

Export JSON for the system columns in cassandra cluster.

cql2json -q "select peer, data_center, host_id, preferred_ip, rack, release_version from system.peers"

Export CSV for the system columns in cassandra cluster.

cql2csv -q "select peer, data_center, host_id, preferred_ip, rack, release_version from system.peers"

Requirement

  • Java8

Installation

General

  1. Download from release page.
  2. Unzip the package.
  3. Add $CQLKIT_PATH/bin to the PATH environment variable

Mac

Install cqlkit via Homebrew.

brew update
brew install cqlkit

Upgrade cqlkit

brew update
brew upgrade cqlkit

Docker

Run cqlkit via Docker.

 docker run --rm -it tenmax/cqlkit

Usage

CQL2CSV

usage: cql2csv [-c contactpoint] [-r cassandraPort] [-q query] [FILE]
File       The file to use as CQL query. If both FILE and QUERY are
           omitted, query will be read from STDIN.

 -c <arg>                            The contact point. if use multi
                                     contact points, use ',' to separate
                                     multi points
    --connect-timeout <arg>          Connection timeout in seconds;
                                     default: 5
    --consistency <LEVEL>            The consistency level. The level
                                     should be 'any', 'one', 'two',
                                     'three', 'quorum', 'all',
                                     'local_quorum', 'each_quorum',
                                     'serial' or 'local_serial'.
    --cqlshrc <arg>                  Use an alternative cqlshrc file
                                     location, path.
    --date-format <arg>              Use a custom date format. Default is
                                     "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
    --fetchSize <SIZE>               The fetch size. Default is 5000
 -h,--help                           Show the help and exit
 -H,--no-header-row                  Do not output column names.
 -k <arg>                            The keyspace to use.
 -l,--linenumbers                    Insert a column of line numbers at
                                     the front of the output. Useful when
                                     piping to grep or as a simple primary
                                     key.
 -p <arg>                            The password to authenticate.
 -r <arg>                            The port to connect to Cassandra, defaults to 9042.
 -P,--parallel <arg>                 The level of parallelism to run the
                                     task. Default is sequential.
 -q,--query <CQL>                    The CQL query to execute. If
                                     specified, it overrides FILE and
                                     STDIN.
    --query-partition-keys <TABLE>   Query the partition key(s) for a
                                     column family.
    --query-ranges <CQL>             The CQL query would be splitted by
                                     the token ranges. WHERE clause is not
                                     allowed in the CQL query
    --request-timeout <arg>          Request timeout in seconds; default:
                                     12
 -u <arg>                            The user to authenticate.
 -v,--version                        Print the version

CQL2JSON

usage: cql2json [-c contactpoint] [-r cassandraPort] [-q query] [FILE]
File       The file to use as CQL query. If both FILE and QUERY are
           omitted, query will be read from STDIN.

 -c <arg>                            The contact point. if use multi
                                     contact points, use ',' to separate
                                     multi points
    --connect-timeout <arg>          Connection timeout in seconds;
                                     default: 5
    --consistency <LEVEL>            The consistency level. The level
                                     should be 'any', 'one', 'two',
                                     'three', 'quorum', 'all',
                                     'local_quorum', 'each_quorum',
                                     'serial' or 'local_serial'.
    --cqlshrc <arg>                  Use an alternative cqlshrc file
                                     location, path.
    --date-format <arg>              Use a custom date format. Default is
                                     "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
    --fetchSize <SIZE>               The fetch size. Default is 5000
 -h,--help                           Show the help and exit
 -j,--json-columns <arg>             The columns that contains json
                                     string. The content would be used as
                                     json object instead of plain text.
                                     Columns are separated by comma.
 -k <arg>                            The keyspace to use.
 -l,--linenumbers                    Insert a column of line numbers at
                                     the front of the output. Useful when
                                     piping to grep or as a simple primary
                                     key.
 -p <arg>                            The password to authenticate.
 -r <arg>                            The port to connect to Cassandra, defaults to 9042.
 -P,--parallel <arg>                 The level of parallelism to run the
                                     task. Default is sequential.
 -q,--query <CQL>                    The CQL query to execute. If
                                     specified, it overrides FILE and
                                     STDIN.
    --query-partition-keys <TABLE>   Query the partition key(s) for a
                                     column family.
    --query-ranges <CQL>             The CQL query would be splitted by
                                     the token ranges. WHERE clause is not
                                     allowed in the CQL query
    --request-timeout <arg>          Request timeout in seconds; default:
                                     12
 -u <arg>                            The user to authenticate.
 -v,--version                        Print the version

cqlsh

Setup the cqlshrc

To connect to cassandra cluster, although we can use -c and -k to specify the contact server and keyspace respectively, to preapre a cqlshrc 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.

  1. Create the cqlshrc file at ~/.cassandra/cqlshrc

  2. Here is the example format.

    [authentication]
    keyspace = system
    
    [connection]
    hostname = 192.168.59.103
    port = 9042
    
    ; vim: set ft=dosini :
    

Import data from a CSV file

$ cql2csv -q "select text_col from ks.tbl" > example.csv

$ ./cqlsh localhost
cqlsh> COPY ks.tbl FROM 'example.csv' WITH ESCAPE='"' AND HEADER=TRUE

Recommended 3rd Party Tools

  • csvkit - A toolkit to handle CSV files. There are many useful CLI tools included.

  • q - Another CSV tool which focuses on query on CSV files.

  • json2csv - Convert JSON format to CSV format

  • jq - a lightweight and flexible command-line JSON processor.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].