Code Monkey home page Code Monkey logo

questdbclient.jl's Introduction

QuestDBClient

This is a Julia package that can be used to connect to a QuestDB database server and send data using the InfluxDB Line Protocol.

This package is strictly used to write data to the database. Reading is not supported. To read data from QuestDB, you can use QuestDB's LibPQ or DBInterface through port 8812. Alternatively, you can read the data over through QuestDB's REST API on port 9000. Visit QuestDB's docs to get more information on how to query data.

Installation at the Julia REPL, using Pkg; Pkg.add("QuestDBClient")

Documentation can be found here.


Basic Examples

Functional Approach:

using QuestDBClient

"""
Assumes the presence of a table called readings created using:

CREATE TABLE readings (
  timestamp TIMESTAMP,
  city SYMBOL,
  temperature DOUBLE,
  humidity DOUBLE,
  make SYMBOL
) TIMESTAMP(timestamp) PARTITION BY DAY;
"""

## Create a sender instance that will connect to the localhost at port 9009
sender = Sender()

## Connect the sender to the server first
connect(sender)

## Create ILP records
sender |>
    x -> table(x, :readings) |> 
    x -> symbol(x, :make => :Omron) |>
    x -> symbol(x, :city => :Nairobi) |>
    x -> FloatColumn(x, :temperature => 26.8) |> 
    x -> FloatColumn(x, :humidity => 0.51) |>
    x -> AtNow(x)

sender |> 
    x -> table(x, :readings) |> 
    x -> symbol(x, :make => :Honeywell) |> 
    x -> symbol(x, :city => :London) |>
    x -> FloatColumn(x, :temperature => 22.9) |> 
    x -> FloatColumn(x, :humidity => 0.254) |>
    x -> AtNow(x)

sender |> 
    x -> table(x, :readings) |> 
    x -> symbol(x, :make => :Omron) |> 
    x -> symbol(x, :city => :Bristol) |>
    x -> FloatColumn(x, :temperature => 23.9) |> 
    x -> FloatColumn(x, :humidity => 0.233) |>
    x -> AtNow(x)
    

## Flush the output to the server
QuestDBSender.flush(sender)

## Close the socket connection
## Close first calls QuestDBSender.flush(sender) as part of its definition
QuestDBSender.close(sender)

Macro based approach:

using QuestDBClient

"""
Assumes the presence of a table called readings created using:

CREATE TABLE readings (
  timestamp TIMESTAMP,
  city SYMBOL,
  temperature DOUBLE,
  humidity DOUBLE,
  make SYMBOL
) TIMESTAMP(timestamp) PARTITION BY DAY;
"""

## Connects to the localhost at port 9009
sender = Sender()

## Connect the sender to the server first
connect(sender)

## Create ILP record statements
sender |>
    @table(:readings) |>
    @symbol(:make => :Omron) |>
    @symbol(:city => :Lisbon) |>
    @FloatColumn(:temperature => 24.8) |>
    @FloatColumn(:humidity => 0.334) |>
    @AtNow

sender |>
    @table(:readings) |>
    @symbol(:make => :HoneyWell) |>
    @symbol(:city => :Kisumu) |>
    @FloatColumn(:temperature => 30.2) |>
    @FloatColumn(:humidity => 0.54) |>
    @AtNow

sender |>
    @table(:readings) |>
    @symbol(:make => :Omron) |>
    @symbol(:city => :Berlin) |>
    @FloatColumn(:temperature => 26.1) |>
    @FloatColumn(:humidity => 0.45) |>
    @AtNow

## Flush the output to the server
QuestDBSender.flush(sender)

## Close the socket connection
## Close first calls QuestDBSender.flush(sender) as part of its definition
QuestDBSender.close(sender)

Roadmap Features

  • Sender Auth and TLS implementation.
    • Find or implement ecdsa in Julia.
  • Error propagation from QuestDB Server.
  • Re-implement the sender's buffer (it's currently just a String).
  • Extend DataFrames support to support of Julia's Table Interface.
  • Allow for the extending of the API by the user who can add types and define how they'll be added to an ILP record statement.

questdbclient.jl's People

Contributors

ochibobo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

questdbclient.jl's Issues

Does it work for Influx (and others)? Should the name then be changed?

Since it works for the "InfluxDB Line Protocol". I looked at Influx and QuestDB at the time, but not in too much detail. It it just that the latter is your focus?

Should there be some generic name that fits both, or should it then be Influx?

Even with no change, should Influx DB use be clarified in the docs?

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

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.