Beginner - Database Handling

Hi all,

Past week I have been moving from Filemaker and learning this whole Xojo. So far looks great but with more learning to come.
I am looking at more database orientated desktop apps for now and want advise on how to manage the sqlite files.

This is what I was thinking:
Open App > Window with “New” button to create a new database file with custom name and “Open” so user can open the data they want.

If I am creating a new database file however it won’t have the tables and fields I need.
When I build the App could I store a blank DB file and when the user hits new and gives it a name it just copies it from the app resources folder for example to their folder of choice?

Thanks in advance and hope what I am trying to achieve makes sense.

I think the more common approach is to simply create the db in code. There are examples in the docs I believe. Just google for xojo create database and see if that helps.

Most of use create the database in code. That’s more work in the beginning. You can either do SQL like:

db.SQLExecute("CREATE TABLE Persons(Name, Age)")

Some databases allow a different API like Valentina:

dim MessageTable as VTable = ValentinaDB.CreateTable("Message") dim MailboxID as VObjectPtr = new VObjectPtr("MailboxID", MailboxTable, EVOnDelete.kCascade) dim User2 as VString = new VString("Username", 100) dim OriginatorFrom as VVarChar = new VVarChar("OriginatorFrom", 1000)

The huge benefit of this is that you can now check the schema version and do your updates sequentially:

if schemaversion = x then add field elseif schemaversion = y then add table end if

Hello Adam,
If you don’t want to do everything by yourself: use ARGEN.
BR Rainer

Thanks! As you say a little more work in the beginning but then it is done.

[quote=492807:@Rainer Greim]Hello Adam,
If you don’t want to do everything by yourself: use ARGEN.
BR Rainer[/quote]

Just had a look and it seems fairly impressive. Thanks for the tip!

HI Adam, my past is FoxPro and there I have frameworks like promatrix and vfp. Almost 3 years ago I made the switch to XOJO. So I was looking for something which can help me. So I discovered ARGEN.
BTW : There will be a Omege Bundle this year. I purchased the last one. I also contains Valentina, and a lot more.
And the price is fair.
BR Rainer

For ease of reference, see Omegabundle for Xojo 2020 Developer Tools Bundle Announced.

So, BR, do you mostly/solely use the Valenta DB for your Xojo apps? If so, can you compare it to other SQL databases?

My preferred approach is to create the DB schema using a UI design tool. Once I have all of the tables, indexes, views, etc that I want then export the DB to a SQL Create script. If I do this, can I use that script in Xojo app to create the DB for the end-user?

i prefer to use a database template file in resource folder, you can create it with the free tool DB Browser (SQLite),
in the ide you need a build step at the correct place, it will copy this file into the build /resource folder.
at runtime you can copy this template where you or the use want if a new db is needed.

Hi Jim,
One reason why I purchased the last bundle was having a good sql designer and more.,…
But this is only the have of the rent…
You need also to have a version tracking and a tool inside your solutions to manage updates . That’s why I was pointing to ARGEN.
Another option is CAPP: there is also a Xojo conference recording about it.
See : https://youtu.be/DHGOloxaDV8
BR Rainer

I left 4th dimension 15 years ago, looking for something with OOP.
I found realstudio, but found it not to be so user friendly with databases than 4thD
I took me some years to make something usable to kind of replace 4thD
and today, I have a base framework that is far better than what I had and I have OOP.
coming from filemaker is the same way.
argen is an easier way to go, but you will have to get used to it

ps: I left filemaker years before using 4thD because of the very limited scripting language

Hi , as I have changed my role from appdev to build and release mgmt, important for me today is the data. And that’s why i love to have a framework, to make solutions for processes and workflow fast and once.

Maybe different I you develop apps for real customers. But I like the roundtrip approach which is part of argen and promatrix/vfp, or CAPP.

There is always a learning curve and sometimes its also about make or buy…

I tried a lot in the past, …

But its good to start with pencil and paper or a tool. But then you have to learn a tool and maybe loose the focus, of what you really want.

And its also a question of budget…

BR Rainer

Yes that is what I do for SQLite databases. Store the script in a constant and execute it with a single call.

[quote=492812:@Rainer Greim]Hi Jim,
One reason why I purchased the last bundle was having a good sql designer and more.,…
But this is only the have of the rent…
You need also to have a version tracking and a tool inside your solutions to manage updates . That’s why I was pointing to ARGEN.
Another option is CAPP: there is also a Xojo conference recording about it.
See : https://youtu.be/DHGOloxaDV8
BR Rainer[/quote]

I discovered DBSchema (https://dbschema.com/ ) some time ago…

One of the attractions is the file format is a very XML schema, which I parse to generate the corresponding XOJO classes.

Hi James, as usual there are a lot tools supporting you. It also depends ( also in price) on which dB you will stay and what extra benefits these tools should have…

But keep in mind, don’t forget to add these scripts also to your versiontracker, or even better build a database around all these , to have the 360 degree view…

BR Rainer

[quote=492829:@James Dooley]I discovered DBSchema (https://dbschema.com/ ) some time ago…

One of the attractions is the file format is a very XML schema, which I parse to generate the corresponding XOJO classes.[/quote]
Wow! That looks like a great DB tool!
Any chance you would be willing to share your parsing code for classes?

And now years later, it offers OOP.

But expensive for the non-commercial developer.

Please beware:

FileMaker is a database application in its first place.
Xojo/RealStudio/REALbasic is a programming environment,
like BASIC.

And so ?

[quote=492952:@Robert Livingston]And now years later, it offers OOP.

But expensive for the non-commercial developer.[/quote]
it was already some OOP features by the time I left it. but they were really light OOP
and as you said very expensive when deploying and for the developper
it was still cheaper than filemaker by the time.
absolute no regret leaving filemaker for 4thD then for realstudio.

I’m also a FileMaker convert just working my way towards database handling so following this topic with interest. Just love actually programming and not using the frustrating scripting engine in FileMaker.