SQLit

SQLit is a minimal implementation of SQL. It contains a very tiny subset of the Structured Query Language.


There are many unfinished parts, but this project isn't meant to be public-ready; it was just a fun exercise. SQLit is case insensitive, which means SELECT is the same as select.

The Language

There are only 3 attribute data types in SQLit:

  • TEXT - any string of characters e.g 'John Doe'
  • INT - an 64-bit integer
  • FLOAT - a 64-bit float

Strings are a sequence of characters within single quotes ''.


The only arithmetic operations supported in queries are + (plus) and - (minus).


The list of WHERE operators supported are:


  • < (less than)
  • > (greater than)
  • = (equal to)
  • != (not equal to)
  • AND (logical AND)
  • OR (logical OR)

Creating a table

CREATE TABLE people (name TEXT, age INT, address TEXT);

Inserting records

INSERT INTO people (name, age, address) VALUES ('John Doe', 43, 'Earth, Solar');

Querying tables

SQLit allows requesting for all columns using *, as well as specific columns by comma-separating them.

SELECT * FROM people; // Select all people

SELECT name, age FROM people; // Select the name and age attributes of all people

SELECT * FROM people WHERE age > 5; // Select only if the person's age is over 5

Updating records

UPDATE people SET age=50 WHERE name='John Doe'; // Change John Doe's age to 50

Deleting records

DELETE FROM people WHERE name='John Doe'; // Delete John Doe's record
DELETE FROM people; // Delete all records

Try it out

A test database has been created and populated with a people table.

Try out the language below:


#>