GithubHelp home page GithubHelp logo

watsy0007 / exduckdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elixir-sqlite/exqlite

0.0 0.0 0.0 810 KB

A DuckDB driver for Elixir

License: MIT License

C 50.10% Elixir 46.84% Makefile 3.06%

exduckdb's Introduction

exduckdb

A quick-n-dirty Elixir DuckDB library.

Mostly true to the original fork of Exqlite, currently tracking version 0.6.0 of DuckDB through git submodules.

Implemented using the provided sqlite3_api_wrapper from DuckDB.

Caveats

Upstream Sqlite caveats

  • Prepared statements are not cached.
  • Prepared statements are not immutable. You must be careful when manipulating statements and binding values to statements. Do not try to manipulate the statements concurrently. Keep it isolated to one process.
  • Simultaneous writing is not supported by SQLite3 and will not be supported here.
  • All native calls are run through the Dirty NIF scheduler.
  • Datetimes are stored without offsets. This is due to how SQLite3 handles date and times. If you would like to store a timezone, you will need to create a second column somewhere storing the timezone name and shifting it when you get it from the database. This is more reliable than storing the offset as +03:00 as it does not respect daylight savings time.

Installation

defp deps do
  {:exduckdb, "~> 0.9.0"}
end

Configuration

config :exduckdb, default_chunk_size: 100
  • default_chunk_size - The chunk size that is used when multi-stepping when not specifying the chunk size explicitly.

Usage

The Exduckdb.DuckDB module usage is fairly straight forward.

# We'll just keep it in memory right now
{:ok, conn} = Exduckdb.DuckDB.open(":memory:")

# Create the table
:ok = Exduckdb.DuckDB.execute(conn, "create table test (id integer primary key, stuff text)");

# Prepare a statement
{:ok, statement} = Exduckdb.DuckDB.prepare(conn, "insert into test (stuff) values (?1)")
:ok = Exduckdb.DuckDB.bind(conn, statement, ["Hello world"])

# Step is used to run statements
:done = Exduckdb.DuckDB.step(conn, statement)

# Prepare a select statement
{:ok, statement} = Exduckdb.DuckDB.prepare(conn, "select id, stuff from test");

# Get the results
{:row, [1, "Hello world"]} = Exduckdb.DuckDB.step(conn, statement)

# No more results
:done = Exduckdb.DuckDB.step(conn, statement)

# Release the statement.
#
# It is recommended you release the statement after using it to reclaim the memory
# asap, instead of letting the garbage collector eventually releasing the statement.
#
# If you are operating at a high load issuing thousands of statements, it would be
# possible to run out of memory or cause a lot of pressure on memory.
:ok = Exduckdb.DuckDB.release(conn, statement)

exduckdb's People

Contributors

warmwaffles avatar kevinlang avatar dmitriid avatar mpope9 avatar dominicletz avatar mindreframer avatar lostkobrakai avatar cw789 avatar mbuhot avatar eiji7 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.