Search notes:

SQLite

An SQLite database is one file

A really cool feature of SQLite is that a database is really just one ordinary file.
This file can be copied from one computer to another, even from Windows to Linux and vice versa.
At times, there is no need to even have a file. In such cases, a transient SQLite database can be created completely in memory.
See also: SQLite: database file.

SQLite runs without server

SQLite does not require a server installation.

Turning off autocommit

SQLite commits every statement by default (so called auto commit).
To turn this behaviour off (which increases performance greatly when lots of statements are executed in sequence), the statements must be enclosed in begin transaction .. commit transaction:
begin transaction;

insert into tab_something values ('foo', 'bar', 'baz');
insert into tab_something values ('one', 'two',  null);
…
…

commit transaction;

pragma

pragma quick_check;

Compiling the amalgamation

«Default» (no optimazation etc.) compilation Shell:

Compiling object files from sqlite3.c

First, we need a few variables:
AMALDIR=sqlite
OBJDIR=/tmp
BINDIR=~/bin
We're now ready to create the object files:
gcc -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_THREADSAFE=0 -Ofast -c $AMALDIR/sqlite3.c -o $OBJDIR/sqlite3-thread-0.o
gcc -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_THREADSAFE=1 -Ofast -c $AMALDIR/sqlite3.c -o $OBJDIR/sqlite3-thread-1.o
gcc -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_THREADSAFE=2 -Ofast -c $AMALDIR/sqlite3.c -o $OBJDIR/sqlite3-thread-2.o

Compiling the shell executable

Note, -lpthread is required if the object file was created with the macro SQLITE_THREADSAFE set to 1 or 2:
gcc $AMALDIR/shell.c $OBJDIR/sqlite3-thread-0.o -ldl           -o $BINDIR/sqlite3-shell-thread-0
gcc $AMALDIR/shell.c $OBJDIR/sqlite3-thread-1.o -ldl -lpthread -o $BINDIR/sqlite3-shell-thread-2
gcc $AMALDIR/shell.c $OBJDIR/sqlite3-thread-2.o -ldl -lpthread -o $BINDIR/sqlite3-shell-thread-2
Make a particular executable the default:
ln -s $BINDIR/sqlite3-shell-thread-0 $BINDIR/sqlite3-shell
sqlite3-shell :memory: 'pragma compile_options'

No readline support

Unfortunately, when compiled as outlined above, there is no readline support.
It seems it needs to be enabled already when configuring the project.

PHP

It seems sqlite can be accessed (in Ubuntu) from PHP with
sudo apt-get install php-sqlite3

Using PowerShell to find SQLite databases in a file system

The following simple PowerShell pipeline finds SQLite databases below the current directory in a file system:
get-childItem  -recurse -attributes !directory |
   foreach-object {
      $firstCharacters = ([char[]] (get-Content $_.fullName -encoding byte -totalCount 15)) -join ''
      if ($firstCharacters -eq 'SQLite format 3') {$_}
   }

Trivia

The default prefix for temporary files used to be sqlite_ but was changed to etilqs_ so that annoyed users wouldn't find the phone numbers of the SQLite developers when googling for sqlite.

TODO

Forking, threads and caching statements accross processes

The FAQuestion Is SQLite threadsafe recommends not to fork() an open SQLite database into a child process.
sqlite3_open_v2 called with with one of the the following flags:
Flag threading mode
SQLITE_OPEN_NOMUTEX multi-thread Multiple threads can use the same database provided each thread has its own database connection.
SQLITE_OPEN_FULLMUTEX serialzed Multiple threads can use the same database, critical code is secured with mutexes.
The value define/macro SQLITE_THREADSAFE specfies the threading mode at compile time.
This thread has some interesting insights.

See also

tables, views, indexes
data types
SQL statements, functions
transactions
SQLite shell
The c interface
Perl module DBD::SQLite
~/.sqliterc
SQLite internals
SQLite performance
Code snippets
Python's sqlite3 standard library
The R package SQLite.
PHP: Accessing an SQLite database with PDO

Windows 10

Apparently, Windows 10 also uses SQLite, see winsqlite3.dll under %SystemRoot%\System32.
See also sqlceoledb40.dll which seems to be the OLE DB provider for SQLite.

Links

SQLiteForExcel (on github) is a small, easy-to-use, open source SQL library to give access to sqlite from VBA.
Open Source SQLite ODBC Driver
SQLite archives might be a really cool replacement for zip or tar files.
The .NET namespace System.Data.SQLite
An experiment that tries to load the OpenStreetMap database into SQLite.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1737228639, '18.218.128.229', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQLite/index(230): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78