Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:36 12 Jun 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

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 Kingdom
Posts: 4281
Posted: 09:24am 07 Jun 2025
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 1278
Posted: 09:46am 07 Jun 2025
Copy link to clipboard 
Print this post

RFO BASIC has SQL

For Android, though.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4281
Posted: 12:28pm 07 Jun 2025
Copy link to clipboard 
Print this post

Thanks @PhenixRising,

I might use that as inspiration.

  Quote  For Android, though.


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 Kingdom
Posts: 4021
Posted: 12:55pm 07 Jun 2025
Copy link to clipboard 
Print this post

Go for it - in MMBasic :)

John
 
grumpyoldgeek
Newbie

Joined: 30/07/2018
Location: United States
Posts: 35
Posted: 08:19pm 07 Jun 2025
Copy link to clipboard 
Print this post

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: Australia
Posts: 562
Posted: 11:35pm 07 Jun 2025
Copy link to clipboard 
Print this post

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: Canada
Posts: 531
Posted: 04:07am 08 Jun 2025
Copy link to clipboard 
Print this post

  thwill said  In order to support a personal project (some Dungeons & Dragons thing)


Looking forward to seeing what this is!
Edited 2025-06-08 14:07 by PeteCotton
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4281
Posted: 07:27am 08 Jun 2025
Copy link to clipboard 
Print this post

  PeteCotton said  Looking forward to seeing what this is!


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 Kingdom
Posts: 7735
Posted: 08:24am 08 Jun 2025
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 4281
Posted: 08:37am 08 Jun 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  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$().


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 States
Posts: 3337
Posted: 01:39pm 08 Jun 2025
Copy link to clipboard 
Print this post

  thwill said  Also having an SQL capable version of MMB4L (probably mySQL/MariaDB in the end rather than SQLite) extends my possible usage in the future.


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 Kingdom
Posts: 1278
Posted: 02:19pm 08 Jun 2025
Copy link to clipboard 
Print this post

Great excuse to shuffle MMB4L over to Android because Android has built-in SQL

 
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025