mrshankly / aqlc

Erlang client for AntidoteDB's SQL interface (AQL)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aqlc

CI Hex.pm

Erlang client for AntidoteDB's SQL interface (AQL). You will need at least Erlang/OTP 22.0, this library won't compile in previous versions.

Quick Start

Connecting to the server

Assuming you have at least one AQL node running, you can connect to it with aqlc:connect/2:

Conn = aqlc:connect("127.0.0.1", 8321).

Once done, you should close the connection with aqlc:close/1:

aqlc:close(Conn).

For instructions on how to launch AQL and AntidoteDB instances, check the documentation here and here.

Queries

To issue queries, use the aqlc:query/2 function:

CreateTable = "CREATE UPDATE-WINS TABLE Artist (ArtistID INT PRIMARY KEY, Name VARCHAR);".
aqlc:query(Conn, CreateTable).

aqlc:query(Conn, "INSERT INTO Artist (ArtistID, Name) VALUES (42, 'Joee');").

aqlc:query(Conn, "SELECT * FROM Artist WHERE ArtistID = 42;").

Transactions

aqlc:query/2 runs the given query in a single transaction. To run multiple queries in a single transaction use aqlc:start_transaction/1 and aqlc:query/3:

Tx = aqlc:start_transaction(Conn).
aqlc:query(Conn, "UPDATE Artist SET Name = 'Joe' WHERE ArtistID = 42;", Tx).
aqlc:query(Conn, "SELECT * FROM Artist WHERE ArtistID = 42;", Tx).

You may commit a transaction with aqlc:commit_transaction/2:

aqlc:commit_transaction(Conn, Tx).

Or abort it with aqlc:abort_transaction/2:

aqlc:abort_transaction(Conn, Tx).

About

Erlang client for AntidoteDB's SQL interface (AQL)

License:Apache License 2.0


Languages

Language:Erlang 100.0%