• Stars
    star
    122
  • Rank 281,628 (Top 6 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated 20 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Erlang NIF for sqlite

Esqlite Test

An Erlang nif library for sqlite3.

Introduction

This library allows you to use the excellent sqlite engine from erlang. The library is implemented as a nif library, which allows for the fastest access to a sqlite database. This can be risky, as a bug in the nif library or the sqlite database can crash the entire Erlang VM. If you do not want to take this risk, it is always possible to access the sqlite nif from a separate erlang node.

Special care has been taken not to block the normal erlang scheduler of the calling process. This is done by handling neccesary commands from erlang by using a dirty scheduler.

SQLite Compile Options

Esqlite contains an embedded version of sqlite3. Currently version 3.45.2 is embedded in the repositoy. It is also possible to use sqlite provided by the system by using the ESQLITE_USE_SYSTEM environment flag.

When sqlite is compiled, the following compile flags are used. These flags are recommended by sqlite.

SQLITE_DQS=0 SQLITE_THREADSAFE=1 SQLITE_DEFAULT_MEMSTATUS=0
SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 SQLITE_LIKE_DOESNT_MATCH_BLOBS
SQLITE_MAX_EXPR_DEPTH=0 SQLITE_OMIT_DEPRECATED
SQLITE_OMIT_PROGRESS_CALLBACK SQLITE_USE_ALLOCA
SQLITE_OMIT_AUTOINIT SQLITE_USE_URI
SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_FTS4
SQLITE_ENABLE_FTS5
SQLITE_ENABLE_MATH_FUNCTIONS
SQLITE_ENABLE_JSON1
SQLITE_ENABLE_RTREE
SQLITE_ENABLE_GEOPOLY

The use of flag SQLITE_DQS=0 is new in version 0.7. It can lead to incompatibilities with respect to the use of single and double qouted values. Historically sqlite didn't differentiate between double and single quoted values, but SQL does. In retrospect, the authors of sqlite, think this was a mistake, and introduced this compile flag to correct this mistake. It means that string literals must use single quotes:

INSERT INTO table VALUES('abcd', 1234);

When double quotes are used the value is seen as object values in SQL. So a query like:

INSERT INTO table VALUES("abcd", 1234);

Will not work, because it sees the value 'abcd' as a SQL object value, and not a string literal.

Version 0.8.0

This version is a major derivation from previous versions. When I started with this library it was implemented by using a separate os level thread per connection. At the time this was the only way to use functions in C which take longer to process than 1ms. A lot has changed since then. The VM now has dirty schedulers which make it possible to remove the thread per connection. This makes it possible to open a lot more connections. On the SQLite side some things have also changed. Extended error codes, introspection into the internals. This release modernizes the integration. In some places the API is no longer compatible and will require small changes. In order to ease this process the library now has typespecs, and the documentation was extended.

More Repositories

1

breaky

Fusebox provides a way to supervise and manage modules and processes depending on external resources.
Erlang
46
star
2

elli_websocket

Elli Websocket Handler
Erlang
19
star
3

educkdb

DuckDB NIF for Erlang
C++
15
star
4

esql

ESQL provides an abstraction layer between Erlang programs and SQL relational databases. This lets you write database code once, in Erlang, and have it work with any number of backend SQL databases (Sqlite, MySQL, Oracle, PostgreSQL, ODBC-compliant databases, etc.)
Erlang
15
star
5

eiconv

Erlang iconv NIF wrapper
Erlang
10
star
6

diffy

Erlang diff match and patch implementation
Erlang
8
star
7

hedgy

Hedgy, another flavor of web(z)machine
Erlang
6
star
8

mod_geoip

Geoip module for Zotonic -- Uses the maxmind database.
Erlang
5
star
9

mod_sse

Zotonic module implementing Server Sent Events
Erlang
4
star
10

zotonic_mod_teleview

Mod teleview provides live updating server rendered views.
Erlang
4
star
11

pgsql

Pure erlang interface for postgres
Erlang
3
star
12

mmqtt

Modular MQTT
Erlang
3
star
13

vagrant-zotonic

Vagrant setup for zotonic development with R16 from Erlang Solutions.
Shell
2
star
14

esql_pgsql

Postgres driver for ESQL
Erlang
2
star
15

esql_odbc

Odbc driver for ESQL
2
star
16

esql_sqlite3

Sqlite3 driver for ESQL.
Erlang
2
star
17

zotonic_folsom

Send zotonic stats to folsom
Erlang
1
star
18

mod_sparky

Easily create sparklines in pages on your Zotonic site.
JavaScript
1
star
19

mod_dashboard

Zotonic module for constructing dashboards.
JavaScript
1
star
20

mod_component_example

A module with some examples for working with Zotonic's mod_component
JavaScript
1
star
21

ecrypt

Experimental proof of concept crypto nif using OpenSSL's engine api.
C
1
star
22

borkbork

Swedish chef inspired experiment room
Erlang
1
star
23

tubby

A process pool for running tasks.
Erlang
1
star