15 releases

0.3.2 Feb 1, 2025
0.3.1 Feb 1, 2025
0.3.0 Jan 26, 2025
0.2.4 Jan 23, 2025
0.1.2 Dec 28, 2024

#207 in Network programming

Download history 294/week @ 2024-12-23 174/week @ 2024-12-30 701/week @ 2025-01-06 234/week @ 2025-01-13 216/week @ 2025-01-20 304/week @ 2025-01-27 85/week @ 2025-02-03

1,047 downloads per month

MIT license

300KB
583 lines

Esque

SQ: The Simple Query Tool

SQ is a modern database, written from the ground-up to take advantage of Phext: 11-dimensional plain hypertext. Like normal SQL databases, it has multiple pronunciations: "esque", "S-Q", and "Seek".

Getting Started

  • sq help: displays online help
  • sq : launches a server that hosts a phext file via shared memory
  • sq status: Displays daemon statistics (loaded phext, size, connection count)
  • sq push : Overwrites the specified scroll with the local file
  • sq pull : Fetches the specified scroll to a local file
  • sq select : Fetches content from the current phext
  • sq insert "text": Appends text at the specified coordinate
  • sq update "text": Overwrites text at the specified coordinate
  • sq delete : Removes all content from the specified coordinate
  • sq save : Writes the current phext back to disk
  • sq init: Fast initialization for hosting world.phext from any state
  • sq shutdown: Instruct the daemon to terminate

Modes of Operation

  • Daemon Mode: If you supply a filename parameter to sq, it will launch in daemon mode - communicating with local system processes via shared memory
  • Listening Mode: If you supply a port number to sq, it will launch in web server mode - listening on the TCP socket requested

SQ Design Philosophy

SQ is a complete ground-up rewrite of database concepts. It probably doesn't have features you expect from a database. What it does offer is simplicity. SQ is designed to mirror computer architecture in 2025, not 1970. Databases are stored in phext files using variable-length scrolls. Essentially, everything in a phext database is a string.

SQ leverages Rust and libphext as a core data store. All database primitives in SQ are built in terms of phext. For more information about the phext encoding format, refer to https://phext.io.

Developing

In daemon mode, SQ uses shared memory to ensure that data transfers to/from the database engine are done as quickly as possible. The shared memory segments are managed by files stored in the .sq directory where you invoked SQ from. It is expected that you will run the client and the server from the same directory.

In listening mode, SQ reads and writes phexts via REST.

REST API Endpoint

SQ offers a simple CRUD-style REST API. The API allows you to interact with multiple phexts from CURL or your web browser.

  • /api/v2/select?p=&c=: Fetches the scroll of text found at coordinate in phext.phext
  • /api/v2/insert?p=&c=&s=: Appends a scroll of text at coordinate in phext.phext
  • /api/v2/update?p=&c=&s=: Overwrites the contents of the scroll at coordinate in phext.phext
  • /api/v2/delete?p=&c=: Clears the contents of the scroll at coordinate in phext

Linux

  • reset.sh: removes the .sq folder from the file system and starts an instance on world.phext

Windows

  • reset.ps1: same as reset.sh, but in PowerShell

Trivia

The name SQ was inspired by this tweet: https://x.com/HSVSphere/status/1849817225038840016

Dependencies

~2–26MB
~333K SLoC