Compiling out 'undesired' database drivers
Posted: 14.01.2009, 16:36
Hi,
Quite some people want an option to exclude some zeoslib database drivers from their projects, simply because they don't use these databases.
I'm happy to tell you the Parameters documentation file now also has this new chapter.
Two reasons why I did not do it that way:
- Impossible to do that to a stable version.
- It's against the easy swapping principle zeoslib currently uses. Setting a new protocol (eg using an ini file read by your program) is much easier than adding a new component, because last option needs recompilation.
BTW : if you think you never swap just by setting an ini-file : this trick enabled one of my projects to change data import on the fly when a third party program decided to use an other database. Copied the right dll next to my program, changed the parametrised query and changed the protocol setting from mysql to firebird.
This change will be committed to testing branch in a few minutes. (I need the id of this post for the documentation). When the response looks allright I'll also move the changes to 6.6-patches soon.
Mark
Quite some people want an option to exclude some zeoslib database drivers from their projects, simply because they don't use these databases.
I'm happy to tell you the Parameters documentation file now also has this new chapter.
I know some people think different about it. eg. By encapsulating driver specific code into a new component you'd have to add to your project, like a TZMysqlDriver that you can connect to a ZConnection.1. Project options
==================
1.1. Conditional Defines
========================
It is possible to avoid databasedrivers are compiled into your program
executable if you're not planning to support the use of them. You can do
this by commenting out the ENABLE_XXXX DEFINES in zeos.inc before
compiling and installing zeoslib.
A more flexible way is to install zeoslib using the standard zeos.inc
file and add some conditional DEFINE's to your project options. Supported
values are:
* ZEOS_DISABLE_MYSQL
* ZEOS_DISABLE_ORACLE
* ZEOS_DISABLE_SQLITE
* ZEOS_DISABLE_ASA
* ZEOS_DISABLE_INTERBASE
* ZEOS_DISABLE_DBLIB
* ZEOS_DISABLE_POSTGRESQL
* ZEOS_DISABLE_ADO
To use this feature you must add the zeoslib source dir's to the search
path of your project. So only the required features will be compiled in
your project executable. (Make sure the zeoslib units are recompiled as
well)
Two reasons why I did not do it that way:
- Impossible to do that to a stable version.
- It's against the easy swapping principle zeoslib currently uses. Setting a new protocol (eg using an ini file read by your program) is much easier than adding a new component, because last option needs recompilation.
BTW : if you think you never swap just by setting an ini-file : this trick enabled one of my projects to change data import on the fly when a third party program decided to use an other database. Copied the right dll next to my program, changed the parametrised query and changed the protocol setting from mysql to firebird.
This change will be committed to testing branch in a few minutes. (I need the id of this post for the documentation). When the response looks allright I'll also move the changes to 6.6-patches soon.
Mark