Giter Site home page Giter Site logo

slicingdice / slicingdice-arduino Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 18 KB

Official Arduino client for SlicingDice, Data Warehouse and Analytics Database as a Service.

Home Page: https://www.slicingdice.com/

License: MIT License

C++ 100.00%
slicingdice arduino-client slicingdice-arduino analytics-database data-warehouse database database-as-a-service data-warehouse-as-a-service bi big-data analytics redshift bigquery olap iot-analytics olap-cube dbaas slicingdice-client

slicingdice-arduino's Introduction

SlicingDice Official Arduino Client (v2.0.0)

Official Arduino client for SlicingDice - Data Warehouse and Analytics Database as a Service.

SlicingDice is a serverless, SQL & API-based, easy-to-use and really cost-effective alternative to Amazon Redshift and Google BigQuery.

Code Quality: Codacy Badge

Documentation

If you are new to SlicingDice, check our quickstart guide and learn to use it in 15 minutes.

Please refer to the SlicingDice official documentation for more information on how to create a database, how to insert data, how to make queries, how to create columns, SlicingDice restrictions and API details.

Note

SlicingDice's Arduino client currently supports only data insert commands. Let us know if you application requires Arduino to query data from SlicingDice and we'll make sure to add this feature to our backlog.

Installing

Click here to download our Arduino client as a zip file. After downloading it, you only need to import the zipped contents into your project path.

Usage

#include <SlicingDice.h>
#include <ArduinoJson.h>

// If you need a demo API key visit: https://docs.slicingdice.com/docs/try-before-you-buy
String apiKey = String("YOUR_API_KEY");
// if false will use test end-point, otherwise production end-point
boolean useProduction = false;
SlicingDice sd = SlicingDice(apiKey, useProduction);

void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
    }

    // Arduino network settings, should match your internet connection properties
    byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte ip[] = { 192, 168, 0, 10 };
    byte gateway[] = { 192, 168, 0, 1 };
    byte subnet[] = { 255, 255, 255, 0 };
    byte dns[] = { 8, 8, 8, 8 };
    Ethernet.begin(mac, ip, dns, gateway, subnet);
}

// Send an insert command to Slicing Dice API and print the result
void loop() {
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& data = jsonBuffer.createObject();
    JsonObject& nestedInsertion = data.createNestedObject("[email protected]");
    nestedInsertion["age"] = 22;

    // Auto create non-existent fields
    JsonArray& autoCreate = data.createNestedArray("auto-create");
    autoCreate.add("table");
    autoCreate.add("column");

    // Insert object
    sd.insert(data);

    // Print result for debugging
    Serial.print("Status code: ");
    Serial.println(sd.statusCode);
    Serial.println(sd.response);
}

Tests and examples

Whether you want to test the client installation or simply check more examples on how the client works, take a look at tests directory.

Reference

SlicingDice encapsulates logic for sending requests to the insert endpoint.

Attributes

  • statusCode (int) - HTTP status code after inserting to SlicingDice. Should be 200 in ordinary circumstances or one of the HTTP requests defined at the API errors section.
  • response (String) - Response after inserting data. Useful for debugging purposes.

Constructors

SlicingDice(const char* apiKey, boolean production, const char* host, int port)

  • apiKey (const char*) - API key to authenticate requests with the SlicingDice API.
  • production(boolean) - (Default: true) If true the client will send requests to production end-point, otherwise to tests end-point.
  • host (const char*) - (Default: api.slicingdice.com) Connection endpoint to use when generating requests to SlicingDice.
  • port (int) - (Default: 80) Port to connect to when generating requests. Particularly useful when connect to http://localhost.

void insert(JsonObject& query)

Insert data to existing entities or create new entities, if necessary. This method corresponds to a POST request at /insert.

Request example

#include <SlicingDice.h>
#include <ArduinoJson.h>

// If you need a demo API key visit: https://docs.slicingdice.com/docs/try-before-you-buy
String apiKey = String("YOUR_API_KEY");
// if false will use test endpoint, otherwise production endpoint
boolean useProduction = false;
SlicingDice sd = SlicingDice(apiKey, useProduction);

void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
    }

    // Arduino network settings, should match your internet connection properties
    byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte ip[] = { 192, 168, 0, 10 };
    byte gateway[] = { 192, 168, 0, 1 };
    byte subnet[] = { 255, 255, 255, 0 };
    byte dns[] = { 8, 8, 8, 8 };
    Ethernet.begin(mac, ip, dns, gateway, subnet);
}

// Send an insertion request to Slicing Dice API and print the result
void loop() {
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& data = jsonBuffer.createObject();
    JsonObject& nestedInsertion = data.createNestedObject("[email protected]");
    nestedInsertion["age"] = 22;
    
    // Auto create non-existent fields
    JsonArray& autoCreate = data.createNestedArray("auto-create");
    autoCreate.add("table");
    autoCreate.add("column");

    // Insert object
    sd.insert(data);

    // Print result for debugging
    Serial.print("Status code: ");
    Serial.println(sd.statusCode);
    Serial.println(sd.response);
}

Output example

Status code: 200
{
    "status": "success",
    "inserted-entities": 1,
    "inserted-fields": 1,
    "took": 0.023
}

License

MIT

slicingdice-arduino's People

Contributors

gmenegatti avatar joaosimbiose avatar jzsimbiose avatar matheusportela avatar telles-simbiose avatar

Watchers

 avatar  avatar  avatar

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.