Skip to content

SQLite

SQLite is a lightweight version of other SQL database engines such as MySQL and PostgreSQL.

SQLite is available as a module on Apocrita.

Usage

To run the default version of SQLite, simply load the sqlite module:

$ module load sqlite
$ sqlite3 --help
Usage: sqlite3 [OPTIONS] FILENAME [SQL]

For full usage documentation, run sqlite3 --help.

Full SQL history will be written to a file named .sqlite_history in your home directory.

Example job

Serial job

Here is an example job running running on 1 core and 1GB memory:

#!/bin/bash
#SBATCH -n 1               # (or --ntasks=1) Request 1 core
#SBATCH --mem-per-cpu=1G   # Request 1GB RAM per core
#SBATCH -t 1:0:0           # Request 1 hour runtime

module load sqlite

# print the available databases inside database file "database.db"
sqlite3 database.db .databases

# print the available tables inside database file "database.db"
sqlite3 database.db .tables

# execute SQL statements (i.e. SELECT)
sqlite3 database.db "SELECT * FROM TABLE_NAME"

# dump the database contents into a file
sqlite3 database.db .dump > database.sql

References