![]() |
Forum Index : Microcontroller and PC projects : Is anyone aware of "prior art" for accessing database from a BASIC ?
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4281 |
Hi folks, In order to support a personal project (some Dungeons & Dragons thing) I'm looking at adding some native Database access functionality to MMB4L. Is anyone aware of any prior art regarding syntax for this in a BASIC they have used ? Currently thinking something along the lines of: ' Open database connection. hDb% = DBOPEN("SQLite3", "mydatabase.db") ' Execute SQL query. hQuery% = DBEXECUTE(handle%, "SELECT * FROM my_table") IF hQuery% THEN DO ' Query columns of current row. my_column1$ = DBCOLUMN(hQuery%, "my_column1") my_column2$ = DBCOLUMN(hQuery%, "my_column2") PRINT my_column1$, my_column2$ ' Advance to next row. WHILE DBNEXTROW(hQuery%) LOOP ' Close database connection. DBCLOSE(hDb%) Best wishes, Tom Edited 2025-06-07 19:25 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1278 |
RFO BASIC has SQL For Android, though. |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4281 |
Thanks @PhenixRising, I might use that as inspiration. That doesn't matter, I'm not looking for an implementation, just for an inspiration for the syntax, if left to my own devices it will look like a C-API that has been transpiled into a BASIC API. Of course this is somewhat *insane*, I should just solve my current problem in Python or Go(lang), but where is the fun in that! Anyone else have any suggestions ? Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4021 |
Go for it - in MMBasic :) John |
||||
grumpyoldgeek Newbie ![]() Joined: 30/07/2018 Location: United StatesPosts: 35 |
You might want to take a look at the Pick Operating System. From Wikipedia: "The Pick Operating System is an integrated computing platform with a database, query and procedural operation languages, peripheral and multi-user management, and BASIC programming capabilities. Its database utilizes a hash-file system, enabling efficient data storage and retrieval by organizing data into dynamic associative arrays managed by associative files." Edited 2025-06-08 06:23 by grumpyoldgeek |
||||
zeitfest Guru ![]() Joined: 31/07/2019 Location: AustraliaPosts: 562 |
arrgh - TBS just lost my post. The old client-server database systems usually had API's for 3gl based clients. Although the technology has changed now, the access patterns still tend to have the same patterns - tables, sql, cursors (dataset lists), etc. In face most supply an example of "generating an invoice" from tables yada, yada. IMHO the single-user database systems tend to be new and flaky, I would use an older multi-user system that has had solid use. Edited 2025-06-08 09:36 by zeitfest |
||||
PeteCotton![]() Guru ![]() Joined: 13/08/2020 Location: CanadaPosts: 531 |
Looking forward to seeing what this is! Edited 2025-06-08 14:07 by PeteCotton |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4281 |
I'm not sure it's of general use Pete. I'm GMing the "Barrowmaze" mega-dungeon for the girls and I want to have printed sheets of pre-generated "dungeon restock" and "wandering monster encounter" rolls with stat-blocks and treasures so that I don't slow down play at the table doing it the old fashioned way. I could store the necessary data as DATA, but I thought I might instead use it as an opportunity to experiment with advancing MMB4L's capabilities. Best wishes, Tom Edited 2025-06-08 17:28 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7735 |
This looks like a nice little flat file database system. It can probably be done reasonably easily in MMBasic, using one or more index files pointing to the main random access data file. Does it even need SQL? I'd make all the records a fixed length to keep things simple. You can then search a record using INSTR() and access each data item within the record using MID$(). Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4281 |
Absolutely! but where is the "fun" in that ... it's what I'd do if I needed to run on a uC version of MMBasic, but I don't. Also having an SQL capable version of MMB4L (probably mySQL/MariaDB in the end rather than SQLite) extends my possible usage in the future. I'm increasingly using MMB4L for throw-away data-processing scripts at work rather than trying to dust off my Python. Best wishes, Tom Edited 2025-06-08 18:38 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3337 |
Of course as an interim solution, there's always shelling out with the SYSTEM command: mySQL run query bash script linux command line PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
PhenixRising Guru ![]() Joined: 07/11/2023 Location: United KingdomPosts: 1278 |
Great excuse to shuffle MMB4L over to Android because Android has built-in SQL ![]() ![]() |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |