[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    KConfig SQL backend
From:       "Ivan Vasin" <nisavid () gmail ! com>
Date:       2008-07-22 4:18:14
Message-ID: 1b39da190807212118s27f2aedeub7ccde3075fc6bcc () mail ! gmail ! com
[Download RAW message or body]

An SQL-backed configuration backend was incidental to another project
I am working on, so I decided to write a plugin for KConfig which uses
an SQL database instead of the INI-like files used by
KConfigIniBackend. Specifically it uses Qt's database abstraction
layer provided by QSqlDatabase and QSqlQuery. The implementation I
wrote, KConfigMysqlBackend, is hardcoded for MySQL, but creating other
implementations for any other SQL driver supported by Qt is simply a
matter of changing "QMYSQL" to something else in the constructor. If
it could be rewritten as a "KConfigSqlBackend" which somehow accepted
a parameter to select the SQL driver, that would be better, but I
don't know how to do this.

Attached in the archive are the sources for KConfigMysqlBackend
(kconfigmysql_p.h, kconfigmysql.cpp) as well as the kconfigdata.h,
kconfigbackend.h, and kconfigbackend.cpp files copied from
kdelibs/kdecore/config. The backend is installed as a plugin, and the
only simple way to use it (afaik) is the KConfig( dbInfoString,
"MYSQL" ) constructor. The dbInfoString, used in place of the file
name, specifies the connection settings for the database in URL style
(user:pass@host/dbname). The database must exist, and the user granted
privileges on it, prior to its use by KConfig.

I tried to follow the procedure used in KConfigIniBackend as closely
as possible to ensure compatibility. The only thing I couldn't get to
work was the kde_kiosk_exception global, as I could not find any
documentation on it anywhere. Thus I set kde_kiosk_exception = true in
kconfigmysql.cpp.

["kconfigmysql.tar.bz2" (application/x-bzip2)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic