Skip to content

Commit b74f636

Browse files
author
Mikko Juola
committed
First commit. Add SQLite TrailDB.
0 parents  commit b74f636

File tree

4 files changed

+489
-0
lines changed

4 files changed

+489
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.so
2+
*.dylib
3+
*~
4+
*.swp

Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.PHONY: release debug clean
2+
3+
CFLAGS := -Wall -lsqlite3 -ltraildb -shared -fPIC
4+
5+
release: CFLAGS += -O2
6+
release: sqlite3traildb.so
7+
8+
debug: CFLAGS += -Og -g3
9+
debug: sqlite3traildb.so
10+
11+
sqlite3traildb.so: sqlite3_traildb.c
12+
$(CC) -o sqlite3traildb.so sqlite3_traildb.c $(CFLAGS)
13+
14+
clean:
15+
$(RM) sqlite3traildb.so

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
TrailDB for SQLite
2+
------------------
3+
4+
This repository contains an implementation of an extension that exposes
5+
TrailDBs as virtual tables in SQLite.
6+
7+
Compile
8+
-------
9+
10+
There is a `Makefile` in this repository that works on UNIXy systems. Install
11+
SQLite and [TrailDB](https://traildb.io/) first.
12+
13+
```
14+
$ make
15+
```
16+
17+
If compilation is successful, you will have a file `sqlite3traildb.so` in the
18+
current directory that implements the extension.
19+
20+
The `Makefile` for this project is very simple, since this is a single C-file project. If something fails, the command to compile this extension is not much more than:
21+
22+
```
23+
$ gcc -o sqlite3traildb.so sqlite3_traildb.c -O2 -shared -fPIC -ltraildb -lsqlite3
24+
```
25+
26+
Load
27+
----
28+
29+
In SQLite, use `.load` or `LOAD_EXTENSION()` function to load up the extension.
30+
31+
```sql
32+
sqlite> .load ./sqlite3traildb
33+
```
34+
35+
To load a TrailDB as a virtual table, invoke `CREATE VIRTUAL TABLE`:
36+
37+
```sql
38+
sqlite> CREATE VIRTUAL TABLE mytraildb USING traildb ('./path/to/traildb');
39+
sqlite> SELECT * FROM mytraildb;
40+
```

0 commit comments

Comments
 (0)