CrateDB Blog | Development, integrations, IoT, & more

Cr8: a Collection of Utility Scripts for Working with Clusters

Written by CrateDB | 2016-02-12

Mathias Fußenegger, aka 'Jordi', is one of CrateDB's core engineers and a massive Linux fan. During the recent Snow Sprint, amongst other things, Jordi decided to add a random data generator to his CrateDB dev tools project.

Install Cr8

You will need at least Python 3.4, Install with pip.

pip install cr8

Usage

Cr8 has five tools available, which can be found by typing cr8 -h or cr8 <subcommand> -h. These are summarized below.

SQL Statement Runtime

Measure the runtime of a specific SQL statement on a cluster:

cr8 timeit "select * from tweets limit 100"SERVER_IP:4200

Generate an Insert Statement from JSON

To generate an insert statement from a supplied JSON string, ready for use on a Crate cluster:

echo '{"name": "Arthur", "lastname": "Dent"}' | cr8 json2insert mytable

Which will generate:

insert into mytable (lastname, name) values (?, ?)
['Dent', 'Arthur']

Upload a File into a BLOB table

To upload a file from your local file system to a Crate cluster BLOB table:

cr8 uploadSERVER_IP:4200 blobtable /tmp/screenshot.png

Fill a Table with Random Data

To fill a table with randomly generated data from faker:

cr8 fill-TABLESERVER_IP:4200 mytable 100000

In this example, the 100000 is the amount of records you wish to fill. The script will read the table schema and map these to providers from faker.

For more details on Cr8 - Crate Dev Tools and to keep up to date with the project visit the GitHub repository.