What to do if I need a small database  [SOLVED]

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
psion_revo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Feb 07, 2016 10:13 am

What to do if I need a small database

Postby psion_revo » Sun Feb 07, 2016 10:31 am

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.

User avatar
doublemax
Moderator
Moderator
Posts: 11387
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: What to do if I need a small database

Postby doublemax » Sun Feb 07, 2016 11:19 am

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.
Use the source, Luke!

psion_revo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Feb 07, 2016 10:13 am

Re: What to do if I need a small database

Postby psion_revo » Sun Feb 07, 2016 11:47 am

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.

User avatar
doublemax
Moderator
Moderator
Posts: 11387
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: What to do if I need a small database

Postby doublemax » Sun Feb 07, 2016 12:22 pm

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.
Use the source, Luke!

psion_revo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Feb 07, 2016 10:13 am

Re: What to do if I need a small database  [SOLVED]

Postby psion_revo » Sun Feb 07, 2016 3:34 pm

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!

psion_revo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Feb 07, 2016 10:13 am

Re: What to do if I need a small database

Postby psion_revo » Mon Feb 08, 2016 9:22 am

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!


Return to “Database Related”

Who is online

Users browsing this forum: No registered users and 1 guest