Warning
This project is currently an experiment. It is not ready for use, and anything in it may change.
s4ql ("simple storage service + structured query language") is an embedded SQL database engine for Go, in the spirit of SQLite, but with all data stored in S3. It is ACID per database, speaks a strict subset of SQLite's SQL, and serves reads from a local SQLite cache that can be rebuilt from S3 at any time.
What has been agreed is in docs/spec.md, and the supported SQL is in docs/roadmap.md.
Made with ✨sparkles✨ by maragu: independent software consulting for cloud-native Go apps & AI engineering.
Contact me at markus@maragu.dk for consulting work, or perhaps an invoice to support this project?
As of 2026-12-04:
- Works now, through
database/sql, with the packagemaragu.dev/s4qlas the driver:create tableanddrop tableof a strict table with one or more columns, exactly one of them the primary key, and adefaultwith a literal on a column.- The column types
int,integer,real,text, andblob. A value must have the exact type of its column. - Columns that are
not null, and columns that take null. insertof one row, with literals and arguments, with or without a list of columns. A column that the list leaves out gets its default.selectof named columns,*, and expressions, each with an optionalasalias, with awhereof comparisons, ofis nullandis not null, and ofexists (select ...), joined byand. A comparison,is null,is not null, andexists (select ...)may also be result columns. A comparison may have its value on either side. Rows withoutorder bycome in a varying order. Aselectwithoutfromgives one row of values.order byof one or more columns or aliases, each ascending or descending, andlimitwith a number or?, onselect. Alimitneeds anorder bythat holds the primary key, so that it gives the same rows every time.- A scalar subquery in a
where, on the right or the left of a comparison, in aselect, anupdate, and adelete. It is not correlated, and runs once before the statement changes anything. It fails when it finds more than one row. - Arithmetic:
+,-,*,/, and a unary-on integers and reals, in thesetof anupdateand in awhere. An overflow, a division by zero, and an infinite result are errors. A column may be compared with a column of the same type. - Text:
||,lower, andhex, where arithmetic runs. strftimeof the current time, which is read once for each statement.randomblobof the host's random bytes, which are new for each row and each call.- Upserts:
insert ... on conflict (key) do nothinganddo update set ... [where ...], withexcluded.<column>, also in arithmetic and text. updateanddelete, with or without thatwhere. An update may change the primary key, andRowsAffectedis what SQLite reports.returningat the end of aninsert, anupdate, and adelete, with column names or*. Outside a transaction, the statement commits before it gives its first row.create indexanddrop index, on one or more columns, each ascending or descending, not unique. The engine picks the index for awhereby fixed rules.if not existsoncreate tableandcreate index, andif existsondrop tableanddrop index.- Arguments for a plain
?, directly and through prepared statements. - Transactions, also read-only ones.
- Several statements in one
Exec, run one after another.QueryandPreparetake one. - Storage: a database is a log of commits in S3, with a local SQLite cache. One instance at a time holds a lease on it. Commits, recovery after a crash, and replay of the log work.
- Observability: structured log events through
log/slog, and, if the caller passes a tracer provider in the options, OpenTelemetry spans for statements, transactions, commits, the lease, and each request to S3.
- How it is checked: against SQLite with generated statements, in the engine and through
database/sql, in a deterministic simulation with planted bugs, and with mutation testing and fuzzing. The storage is also tested against a real S3-compatible bucket in CI. - Not built:
or, other functions and operators in awhere, arithmetic and text inreturningandvalues, aggregates,offset, more than one row perinsert, and a statement while rows of the same transaction are open. - Next: what is decided next is in the roadmap by area: more operators and functions, and expressions in more places, grouping and joining, and a limit on the memory of an operator.
The roadmap by area, and the slices that were built with how each is checked, are in docs/roadmap.md. What is open in detail is in docs/todo.md.