SlicingDice Documentation

SlicingDice - The All-in-One Solution Documentation

Welcome to the SlicingDice documentation. You'll find comprehensive guides and documentation to help you start working with SlicingDice as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Guides

How to do concurrent multi-insert

First time checking our docs? You might want to start with the right foot by reading our Documentation Guide first.

SlicingDice is very flexible in terms of data insertion, you can use our JDBC and ODBC SQL Drivers, our API-based SQL endpoint or our standard API-based JSON endpoint.

On this page, we show how to perform a concurrent multi-insertion on your SlicingDice database using all the methods available.

The table below shows the data that will be inserted in the examples. In the examples, we will use the default dimension but you can choose any dimension you want.

Entities
State
City

Entity1

CA

San Francisco

Entity2

NY

New York

JDBC and ODBC SQL Drivers

Inserting all the data from the table above with the standard SQL, using the SlicingDice's JDBC and ODBC SQL Drivers.

INSERT INTO default ([entity-id], state, city) VALUES ("Entity1", "CA", "San Francisco");
INSERT INTO default ([entity-id], state, city) VALUES("Entity2", "NY", "New York");

API-based SQL endpoint

Inserting all the data from the table above with the SQL language, using the SlicingDice's API-based SQL endpoint.

$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO default ([entity-id], state, city) VALUES ("Entity1", "CA", "San Francisco"); INSERT INTO default ([entity-id], state, city) VALUES ("Entity2", "NY", "New York");'

API-based JSON endpoint

Inserting all the data from the table above with JSON, using the SlicingDice's API-based JSON endpoint.

$ curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "Entity1": {
            "dimension": "default",
            "state": "CA",
            "city": "San Francisco"
        },
        "Entity2": {
            "dimension": "default",
            "state": "NY",
            "city": "New York"
        }
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

insert_data = {
    "Entity1": {
    		"dimension": "default",
        "city": "San Francisco",
        "state": "CA"
    },
    "Entity2": {
        "dimension": "default",
        "state": "NY",
        "city": "New York"
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY");

        JSONObject insertData = new JSONObject()
        .put("Entity1", new JSONObject()
            .put("dimension", "default")
            .put("city", "San Francisco")
            .put("state", "CA"))
        .put("Entity2", new JSONObject()
            .put("dimension", "default")
            .put("city", "New York")
            .put("state", "NY"))

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

insert_data = {
    "Entity1" => {
        "dimension" => "default",
        "city" => "San Francisco",
        "state" => "CA"
    },
    "Entity2" => {
        "dimension" => "default",
        "city" => "New York",
        "state" => "NY"
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'});

const insertData = {
    "Entity1": {
        "dimension": "default",
        "city": "San Francisco",
        "state": "CA"
    },
    "Entity2": {
        "dimension": "default",
        "state": "NY",
        "city": "New York"
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$insertData = array(
    "Entity1" => array(
        "dimension" => "default",
        "city" => "San Francisco",
        "state" => "CA"
    ),
    "Entity2" => array(
        "dimension" => "default",
        "state" => "NY",
        "city" => "New York"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY");

            var insertData = new Dictionary<string, dynamic>{
                {"Entity1", new Dictionary<string, dynamic>{
                    {"dimension", "default"},
                    {"city", "San Francisco"},
                    {"state", "CA"}
                }},
                {"Entity1", new Dictionary<string, dynamic>{
                    {"dimension", "default"},
                    {"city", "New York"},
                    {"state", "NY"}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)

    insertData := map[string]interface{}{
        "Entity1": map[string]interface{}{
            "dimension": "default",
            "city": "San Francisco",
            "state": "CA",
        },
        "Entity2": map[string]interface{}{
            "dimension": "default",
            "city": "New York",
            "state": "NY",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}