|
Forum Index : Microcontroller and PC projects : PicoDB
| Author | Message | ||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3558 |
"Vibe coding", a fun activity for a long-retired, increasingly mobility-constrained programmer analyst. Following the 4-day project with Claude AI to build a MMBasic database retrieval system, I was not happy that it was so tightly tied to the actual data. I started over with ChatGPT-5.2 with a JSON structure, and spent 2 days on it. I found json to be too bulky for me to like, and the experience with ChatGPT was terrible--many instances of "Page not responding: Wait/Close" with 10-minute waits. Chat said this was normal with long sessions, but that's not what I experience with Claude or Gemini. So I switched to fixed-length records with Gemini, and had a real 5-day grind. Recently read my favorite AI substacker say that 2026 will become "all day, every day" for dedicated users, and that's what it was for me. The result is a generic, multi-table, multi-database relational retrieval system (updates to come). It's 1700 lines long, with far more features than the 2100-line version that Claude came up with. I've implemented the same 500-record fictional person database as with Claude (2 tables), and part of Microsoft's test Northwind database (4 table). It can be broken into the a library section and a user section. The stub of the user section is less than 100 lines long and takes less than 1% of program memory. The remained is loaded with LIBRARY LOAD. Here is how Gemini has documented it (I'm not sure how the formatting will translate here). When I get update access, I will enter this on fruitoftheshed. Project Name: PicoDB - Relational Database Engine for MMBasic PicoDB is a lightweight, fully relational database engine written in MMBasic. It is designed for the RP2350 Pico2 microcontroller (PicoMite) where RAM is somewhat scarce but flash SD card storage is plentiful. It supports both a Native Command Mode and a subset of SQL, allowing for complex data querying, filtering, and reporting on hardware with limited resources. Key Features Dual Mode: Interact via a CLI using Native commands (pipe/unix style) or standard SQL (SELECT, DELETE). Import Wizard: Built-in MAKE-DB command converts standard CSV files into fixed-width binary tables and automatically generates the schema. Relational Engine: Supports Implicit and Explicit Joins across up to 5 open tables simultaneously. Indexing: B-Tree style indexing implementation for instant lookups (O(log n) vs O(n)). Aggregates: Built-in support for COUNT, SUM, AVG, MIN, MAX. Context Switching: Instantly switch databases using USE-DB without restarting the program. 1. Installation 1. Code: Upload db.bas to your device. 2. Help Files: Create two text files on your storage root (SD or Flash) named native.hlp and sql.hlp. (Content provided below). 3. Run: RUN "db.bas" 2. Quick Start (The "30 Second" Tutorial) Step 1: Import Data You don't need to write schema files manually. Just upload your CSV files (with header lines) and run the import wizard. DB:us500> make-db mydata employees.csv,customers.csv This analyzes the CSVs, determines field types (String/Int/Float), creates the mydata.def schema, and converts data to fixed-width binary .dat files. Step 2: Load the Database DB:us500> use-db mydata Switching to database: mydata Database 'mydata' Loaded. 2 Tables, 15 Fields. Step 3: Query (SQL Mode) SQL DB:mydata> MODE SQL (switch back with MODE NATIVE) DB:mydata> SELECT first_name, job_title FROM employees WHERE salary > 50000 ORDER BY last_name 3. Native Command Mode The native mode is optimized for minimal typing and "pipe-like" logic. Syntax: [filter] [actions...] Operators: =, <>, >, <, >=, <= (Numeric and String) ~: Case-insensitive "Contains" (also " LIKE " translates to "~") |: OR operator (city="London" | city="Paris") &: AND operator (Implicit, but can be explicit) 4. SQL Mode (SQLite V2.8 Subset) For users comfortable with standard database syntax. Supported Commands: SELECT [fields] FROM [table] WHERE [condition] ORDER BY [field] LIMIT [n] DELETE FROM [table] WHERE [condition] UNDELETE FROM [table] WHERE [condition] Aggregates: COUNT, SUM, AVG, MIN, MAX Examples: SQL SELECT count(ID) FROM users WHERE active = 'Yes' DELETE FROM logs WHERE date < '2023-01-01' SELECT * FROM sales WHERE region = 'North' ORDER BY amount DESC 5. Technical Specifications Max Tables Open: 5 simultaneous tables. Max Record Size: Configurable (default 256 bytes per row). File Handles Used: #1 - #5: Data Tables (Runtime) #6 - #7: Indexing (Read/Write) (uses MMBasic Structures) #8: Utilities (Help/Schema Loader) #9 - #10: Import Wizard (CSV processing) 6. Appendix: Help Files Save these text files to your storage to enable the built-in help system. native.hlp sql.hlp db.zip ~ Edited 2026-01-19 14:58 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |