Giter VIP home page Giter VIP logo

qbt's Introduction

QBT - Query BigTable

QBT is a small CLI application for querying Google Cloud BigTable, using the Lua programming language to express queries.

Why

cbt is a great tool for managing BigTable tables and column familes, but it's read subcomand is somewhat limited in that it doesn't allow you to provide any filters or transformations to your data.

The other option for ad-hoc queries into BigTable is to write custom scripts in your language of choice, which is quite time-consuming for exploratory queries.

Installation

Requirements

  • Go 1.9+
  • gcloud CLI
go get -u github.com/catkins/qbt
gcloud auth applicatiom-default login

Usage

qbt [--project=<project id>] [--instance=<instance id>] [--prefix=<row key prefix>] query <table> <query>

Example

qbt query my_table 'return row.my_cf["my_cf:haystack"] == "needle"'

# json decoding also included
qbt query my_table '
  json = require("json")
  decoded_value = json.decode(row.my_cf["my_cf:haystack"])
  return decoded_value["nested_field"] == 123
'

Configuration

Configuration can also be provided from the environment by providing the QBT_PROJECT, QBT_INSTANCE, and QBT_PREFIX environment variables, or via CLI flags.

Libraries used

  • GCP client libraries for Go: cloud.google.com/go
  • Cobra for CLI: github.com/spf13/cobra
  • Viper for configuration: github.com/spf13/viper
  • Lua implementation gopher-lua: github.com/yuin/gopher-lua
  • JSON support for gopher-lua: layeh.com/gopher-json
  • Errors: github.com/pkg/errors

Todo / Ideas

  • Tests!
  • Add result transformations
  • Add other output types (eg. YAML, CSV, strings returned from scripts)
  • Add debug logging
  • Queries from file / STDIN
  • Pre-query scripts (eg. to define functions)
  • Add CLI params for specifying range / prefix queries
  • Web server for submitting queries to
  • Other authentication methods

Licence

Copyright 2018 Chris Atkins

MIT

qbt's People

Contributors

catkins avatar smcphill avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

smcphill mbrukman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.