BF-SQLite offers a unique approach to interacting with SQLite databases through BrainFuck, showcasing how complex tasks can be simplified with innovative uses of AI. This project provides a working demo for reading headers, scanning tables, and performing limited SQL operations, all designed to demonstrate the unexpected potential of unconventional programming languages.
BF-SQLite: SQLite File-Format Access in BrainFuck
BF-SQLite is an experimental project designed to interface with SQLite databases using the BrainFuck programming language, employing only standard Linux primitives. This initiative highlights how software typically deemed complex can be constructed quickly with the assistance of AI. Inspired by Matt Shumer's article Something Big is Happening, the project illustrates the capabilities of BrainFuck rather than advocating for its practical application in database operations.
Key Features
- Header Parsing: Read and validate the SQLite header.
- Schema Walking: Navigate through schema pages with ease.
- Table Scanning: Perform a thorough scan of tables, allowing insights into the data structure.
- Column Projection: Limited SQL-style projections are supported, for example:
SELECT name FROM users;
SELECT name, sex FROM users;
- Table Creation: Execute commands to create new demo tables:
CREATE TABLE log (ts INT, value TEXT);
- Data Manipulation: Conduct basic
INSERT,UPDATE, andDELETEoperations on a minimal demo database.
Current Capabilities
The following functionalities have been successfully implemented:
- Reading and validating headers
- Performing page reads
- Walking through schemas
- Scanning demo tables
- Executing simple
SELECTqueries on the demouserstable - Creating a narrow demo table with basic structure
- Conducting small controlled write operations
Operational Overview
The interaction model operates as follows:
SQLite .db file
↑
│ dd / raw page bytes
│
Shell pager
↑
│ ASCII request/response
│
BrainFuck program
The protocol is intentionally designed to be straightforward:
Hreads the 100-byte SQLite header and displays it in hexadecimal format.R <page_size> <page_no>retrieves a page and returns it as hex.W <page_size> <page_no>writes a specified page back in hexadecimal format.
Project Structure
The repository is organized into distinct directories for clarity and efficiency:
bf/- Contains demo programs and BrainFuck helper libraries.examples/- Hosts curated demos and reference sketches.scripts/- Includes pagination, build, and execution helpers.tools/- Offers a Dockerized toolchain.docs/archive/- Contains older planning and maintenance notes.
Scope
BF-SQLite serves specifically as a BrainFuck-driven SQLite file-format demonstration and is not intended to function as a full SQLite replacement or SQL engine.
No comments yet.
Sign in to be the first to comment.