[mythtv] [patch] Initial support for other databases than MySQL

David Härdeman david at 2gen.com
Thu Aug 26 14:15:19 EDT 2004


On Thu, Aug 26, 2004 at 07:28:09AM +0100, Ed Wildgoose wrote:
>What about wrapping the QSqlDatabase object in some way and provide a 
>more mythcentric object that will encapsulate the DB.  This way the DB 
>type or name never enters the main code at all?

That was my first idea as well, however, after looking at the code, it 
seemed superflous (at least for the time being).

There are several reasons for this. First of all, the patch that I sent 
merely moved all of the DB initialization into libmyth (mythcontent.cpp) 
instead of half of the init being done outside mythcontext and the other 
half being done inside...thus I would have submitted it even if my ultimate 
goal wasn't to provide PostgreSQL support. In fact, all that's slightly 
specific to PostgreSQL is 4 lines which add support for the DBType 
variable in the config file.

The patch actually simplifies the general code, if it wasn't for the 
(temporary) compability glue, the result would be a removal of approx 35 
lines of duplicate code, achieving better encapsulation at the same 
time. This number is probably higher if the effects of all modules are 
included.

Second, the QSqlDatabase class is already an encapsulation (as far as 
possible) of the different databases, I am not sure which functionality 
would currently be added to an encapsulation of it (in the future things 
like KickDatabase and other stuff might be good candidates). The general 
code in 95% of the cases performs UPDATE/SELECT/DELETE queries which 
should be compatible between databases without needing a 
wrapper/encapsulation around QSqlDatabase.

The other 5% is the DB specific initialization code (table creation and 
alteration mainly), which can't be wrapped in any sane way anyway.

Finally, there is already a wrapper in MythTV (mythdbcon.h) which is 
updated by this patch. It seems to be used infrequently though (I could 
find one case in the main MythTV module).

Regards,
David



More information about the mythtv-dev mailing list