Page 1 of 1

What to do if I need a small database

Posted: Sun Feb 07, 2016 10:31 am
by psion_revo
I am a new in Codeblocks/wxSmith/wxWidgets.
I am doing an user interface for a home radio network.
And I would like to port it to Android in future.
So, I don't want to use MySQL or something.
I prefer one application all-in-one.

Is it possible to make a small database inside wxGrid objects (let them be tables)?
I suppose that max row count in a largest table will be about 1000.
I think to use first columns for key values and hide them from view.
As I understand, all values inside wxGrid are wxString objects.
I will save each wxGrid (table) into a txt file.
And will load wxGrid objects from txt files on a programm start.
Or it will be so slow?

Thanks.

Re: What to do if I need a small database

Posted: Sun Feb 07, 2016 11:19 am
by doublemax
For around 1000 lines reading and writing to a text file should be fast enough. Alternatively you could use sqlite + wxSQlite3 which works with local files and can be embedded into your application.

Re: What to do if I need a small database

Posted: Sun Feb 07, 2016 11:47 am
by psion_revo
For around 1000 lines reading and writing to a text file should be fast enough.
Thank you.
Alternatively you could use sqlite + wxSQlite3 which works with local files and can be embedded into your application.
In this case, I will need to install SQLite3.
But I really want all-in-one.

And the problem is to choose one of two approach:
1. Use wxGrid objects like tables of the database. Keep all data in wxString objects inside wxGrid object.
2. Keep all data inside arrays. Use wxGrid just to process OnPaint events to show data on the screen. Can you offer something instead of wxGrid object?

Thanks.

Re: What to do if I need a small database

Posted: Sun Feb 07, 2016 12:22 pm
by doublemax
In this case, I will need to install SQLite3.
But I really want all-in-one.
No, you can add the wxSQLite3 and the SQLite Amalgamation source files to your project as if it were your own source files.
1. Use wxGrid objects like tables of the database. Keep all data in wxString objects inside wxGrid object.
2. Keep all data inside arrays. Use wxGrid just to process OnPaint events to show data on the screen. Can you offer something instead of wxGrid object?
You can derive your own class from wxGridTableBase and set it with wxGrid::SetTable().

Or you could use a virtual wxListCtrl which is probably much less work, but also less flexible that using wxGrid.

Re: What to do if I need a small database

Posted: Sun Feb 07, 2016 3:34 pm
by psion_revo
doublemax wrote:No, you can add the wxSQLite3 and the SQLite Amalgamation source files to your project as if it were your own source files.
Good. Will try to do it. But I'm afraid it will need more skills that I have.
doublemax wrote:You can derive your own class from wxGridTableBase and set it with wxGrid::SetTable().
Yes. Thanks! This is near what I really expect to obtain.

Good luck with your projects!

Re: What to do if I need a small database

Posted: Mon Feb 08, 2016 9:22 am
by psion_revo
doublemax wrote:you can add the wxSQLite3 and the SQLite Amalgamation source files to your project as if it were your own source files.
Yes! It works.
Just add to project folder:

Code: Select all

sqlite3.c
sqlite3.h
wx/wxsqlite3.h
wx/wxsqlite3.cpp
wx/wxsqlite3def.h
wx/wxsqlite3opt.h
And add project path to search compile path.
doublemax, thank you very much!