Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "swiplite"

Title:Prolog bindings for SQLite3
Rating:Not rated. Create the first rating!
Latest version:0.2
SHA1 sum:8be0cc945cf9cb4bef7c82f694e3d0e1f3d7ede1
Author:Boris Vassilev <boris.vassilev@gmail.com>

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.28be0cc945cf9cb4bef7c82f694e3d0e1f3d7ede13https://github.com/borisvassilev/swiplite/archive/0.2.zip
0.1.1b151e55053849d23a1eb2cb6ac28fca155f0076c3https://github.com/borisvassilev/swiplite/archive/0.1.1.zip
0.101eee77379899032f179f740c7548651a1b934083https://github.com/borisvassilev/swiplite/archive/0.1.zip

SQLite for SWI-Prolog

The purpose of swiplite is to enable using sqlite3 databases comfortably from SWI-Prolog, without sacrificing efficiency.

The prolog/sqlite.pl provides low-level access to the connection and statement objects.

Requirements

This has been developed and tested on Linux and Mac OS.

You might already have a decently recent version of SQLite installed; you can also install it using the package manager for your OS.

Finally, since this package contains C code, you need CMake and a C compiler.

Installation

The pack has been already published. To get the latest release:

$ swipl pack install swiplite

... or from the top level:

?- pack_install(swiplite).

The code is available in the public GitHub repository https://github.com/borisvassilev/swiplite. To install from the source, clone the repo and install from the pack directory:

$ git clone https://github.com/borisvassilev/swiplite.git
$ cd swiplite
$ swipl pack install .

Alternatively, create an archive and install it locally:

$ git archive --output=swiplite-<version>.tgz <tree-ish>
$ swipl pack install swiplite-<version>.tgz

You can use this method specifically if you want to build the package using the SQLite amalgamation, currently found on its own branch, sqlite3-amalgamation:

$ git archive --output=swiplite-<version>.tgz sqlite3-amalgamation

This last method uses c/sqlite3.c and c/sqlite3.h.

Background

There are many alternatives to using the swiplite pack. Here is a list of questions I have asked myself before I started working on it (and repeatedly ever since), along with attempts at answers.

Why SQL?

There is no good reason to use SQL; other than, it is the standard interface to relational databases.

Why a relational database?

... especially since you are using Prolog already?

Relational databases come with features that are not available out of the box on SWI-Prolog:

  • Foreign key, unique, and check constraints;
  • Disk persistency.

Why SQLite?

SQLite provides a full-featured relational database almost for free, in terms of setup and resources needed.

Why not ODBC?

SWI-Prolog provides a full-features ODBC interface). However, specifically in the case of SQLite, it requires a clumsy setup with extra dependencies and no obvious benefit.

Why not proSQLite?

proSQLite is a mature SWI-Prolog interface to SQLite also available as a pack. Unfortunately, I was not able to figure out how to use it to create prepared statements with SQL parameters and bind values to them.

Why do you need prepared statements?

It is very likely that prepared statements are not that important. On the other hand, there is the cautionary tale of Little Bobby Tables.

Contents of pack "swiplite"

Pack contains 8 files holding a total of 92.1K bytes.