README.md

SiriDB Connector R

Connector for communicating with a SiriDB node

Installation

install.packages('siridbr')

Quick usage

library(siridbr)

siridb <- SiriDB(user="iris", password="siri", dbname="dbtest", server="localhost", port=9000L)

siridb$connect(function(err) {
    if (!is.null(err)) {
        cat('Connection error: ', err)
    } else {
        siridb$close()
    }
})

SiriDBClient

Create a new SiriDB Client. This creates a new client but connect() must be used to connect.

siridb <- SiriDB(
    user="iris",         # database user
    password="siri",     # password
    dbname="dbtest",     # database name
    server="localhost",  # server address
    port=9000L           # server port
)

SiriDBClient.connect

Connect to SiriDB. A callback function can be used to check if the connect is successful.

siridb$connect(function(err) {
    # success: err is NULL
    # error:   err is a string with an error message
    if (!is.null(err)) {
        cat('Connection error: ', err)
    }
})

SiriDBClient.query

Query SiriDB. Requires a string containing the query and a callback function to catch the result.

The callback function will be called with two arguments: - first argument: A response Object - second argument: Number indicating the status. The status is 0 when successful or a negative value in case of an error. (see Status codes for the possible status codes)

siridb$query("select * from /.*series/", function(resp, status) {
    // success: status is 0 and resp is an Object containing the data
    // error:   status < 0 and resp.error_msg contains a description about the error
    if (status) {
        cat('Query error: ', resp$error_msg, status)
    } else {
        cat(resp)
    }
})

SiriDBClient.insert

Insert time series data into SiriDB. Requires an Array with at least one series Object.string containing the query and a callback function to catch the result.

The callback function will be called with two arguments: - first argument: A response Object - second argument: Number indicating the status. The status is 0 when successful or a negative value in case of an error. (see Status codes for the possible status codes)

series = list(
    list(
        name='example',     # name
        points=list(
            list(timestamp=1500000000, value=0L),   # time-stamp, value
            list(timestamp=1500000900, value=1L)    # etc.
        )
    )
)

siridb$insert(series, function(resp, status) {
    // success: status is 0 and resp.success_msg contains a description about the successful insert
    // error:   status < 0 and resp.error_msg contains a description about the error
    if (status) {
        cat('Insert error: ', resp$error_msg, status)
    } else {
        cat(resp.success_msg)   # insert message
    }
})

SiriDBClient.close

Close the connection.

siridb$close()

Events

TODO

Status codes

Sometimes its useful to act on a specific error, for example you might want to retry the request in case of ERR_SERVER while a ERR_INSERT error indicates something is wrong with the data.

The following status codes can be returned:

Version info

Show version info.

siridb$version()


SiriDB/siridb-connector-r documentation built on May 5, 2019, 9:44 p.m.