SQLite

SQLite

SQLite [1]  is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the world with more applications than we can count, including several high-profile projects.

SQLite in HPC

C Interface Tutorial [2] 

Request a compute node

srun --pty bash

Load the module

module load sqlite

Create a database test.db in your current directory

sqlite3 test.db 

SQLite version 3.8.11.1 2015-07-29 20:00:57 Enter ".help" for usage hints.

You will find the databse "test.db" created in your current directory.

Create a table and insert values

sqlite> create table tbl1(one varchar(10), two smallint); sqlite> insert into tbl1 values('hello!',10); sqlite> insert into tbl1 values('goodbye', 20);

Run the query

sqlite> select * from tbl1;

output: 

hello!|10 goodbye|20

Exit

sqlite> Ctrl+Z

Copy the C file  "sqlite.c" from /usr/local/doc/SQLITE

cp /usr/local/doc/SQLITE/sqlite.c .

Compile

gcc -o sqlite sqlite.c -lsqlite3

Run

./sqlite test.db 'select * from tbl1'

output:

one = hello!

two = 10

one = goodbye

two = 20

References:

[1] SQLite Home

[2] SQLite Tutorial