Which database library should I use?

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
summer
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Nov 03, 2009 11:21 am

Which database library should I use?

Post by summer »

My company uses an MSSQL database and I need a way to communicate with it through wxWidgets 2.9.0. Its currently only a console application where all classes make use of wxString/wxDateTime and wxWidgets RTTI, with no use of STL (there'll be a GUI later).

First of all: Is this stupid? Should I program the objects in STL and convert them to something wxWidgets understands when the GUI needs it? (Being a C# developer I'm not used to this type of converting for instance a string to another type of a string and so on...).

Now for the database problem. Searching through this forum shows that alot of people in here is using DatabaseLayer. Searching forums on Google shows that SOCI is the most recommended library. And then there's also libodbc++, POCO C++ Libraries and the list probably goes on and on. It's a jungle!

I need to perform SQL-operations like update, insert, select and retrieve the just executed "insert"-query's ID.

Any recommandations?
lollisoft
Earned some good credits
Earned some good credits
Posts: 115
Joined: Sat Jul 23, 2005 3:52 pm
Location: Germany
Contact:

Post by lollisoft »

There are really different approaches. I have also written my own database library that is based on some pure abstract classes (interfaces), thus I am able to switch between different variants at runtime.

So if you are not sure what to use think about a similar approach. That way the GUI uses your own thin abstraction over the directly using the other database API's. My approach is also about not depending to any other framework. I can use my database stuff (ODBC) in plain console apps without linking against wxWidgets.

It later was very less work to create a wrapper around wxDatabaseLayer to enable usage of Sqlite without changing all
my code.

OTOH it is a little more overhead and may be a bit slower, but for a GUI CRUD application this is no pain.

Regards

Lothar
OS: Windows 7, Mac OS X (Panther/Leopard/Snow Leopard), SuSE Linux, Debian (PPC), OpenMoko FreeRunner
Compiler: OpenWatcom, GCC
wxWidgets 2.8.x
IDE Makefile based.
RAD My own brewed, Code generation with XSLT and DialogBlocks
phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Re: Which database library should I use?

Post by phlox81 »

summer wrote:My company uses an MSSQL database and I need a way to communicate with it through wxWidgets 2.9.0. Its currently only a console application where all classes make use of wxString/wxDateTime and wxWidgets RTTI, with no use of STL (there'll be a GUI later).
You should think about using STL and Standard C++, as it makes you more flexible.
summer wrote: First of all: Is this stupid? Should I program the objects in STL and convert them to something wxWidgets understands when the GUI needs it? (Being a C# developer I'm not used to this type of converting for instance a string to another type of a string and so on...).
Sure. Mostly you don't realy need this even.
summer wrote: Now for the database problem. Searching through this forum shows that alot of people in here is using DatabaseLayer. Searching forums on Google shows that SOCI is the most recommended library. And then there's also libodbc++, POCO C++ Libraries and the list probably goes on and on. It's a jungle!
For ODBC, I would recommend using the DTL. Fine written Library, stable for years.
Also take a look at Qt, Qt has its own Database abstraction build in, connected to a model/view arcitecture. I would write a DB Frontend today rather in Qt then wxWidgets.
http://doc.trolltech.com/4.5/examples.html#sql

SOCI is a very fine library too. But it lacks MSSQL Support. So you have to use ODBC anyways, and there is DTL the better library imho.

phlox
Post Reply