[fpc-pascal]Common database access in Pascal

Fernando Lozano fsl at centroin.com.br
Thu Jul 25 23:40:22 CEST 2002


Hi Michael,

> > [Common DB access]
> >
> Your remarks are to the point. I have started to code something like
> 
> TDatabase
> TTransaction
> TDBDataset
> 
> Which would cooperate together much like you would expect them to.
> 
> >From TDatabase/TDBdataset etc, a specific descendent should be made for
> each type of database. The Interbase components at this point do this.
> unfortunately, the mysql components don't (not yet). It is my idea to
> finish this work, but due to lack of time, I cannot start working on
> this yet. (3 zillion other things requiring attention...)
> 
> If you're looking for a unified approach in the sense of Borland's BDE
> or even DBExpress, I have no plans for implementing this for the very
> simple reason that I don't believe in this approach: If you want unified
> database access, then I see more sense in making a set of
> TODBCDatabase/TODBCTransaction/TODBCDataset
> descendents which can then be used to access any needed database.

Well, having a unified DB API like Perl DBI, PHP PEAR, Java JDBC and others saves much development time. It's not nice to change lots of lines of code just to move from one database to another.

I don't know how much work is involved for the designer of the API and the developer of the drivers, but I guess that with so many sucessfull free software DB APIs availabe it shouldn't be so hard to pick one of them and mimic its structure and implementation.

Each Database class could have its own unique methods for its unique capabilites, but the standard connect/query/iterate should work the same way for any database, ideally using dynamic loading of libraries so the application don't need even to be recompiled to use a different DB.

About using ODBC this does not look like a good idea except because it won't need a lot of custom drivers. No one uses ODBC to provide drivers although everyone can use ODBC when they have no driver availabe. It's much easier, for example, to use Perl DBD::Oracle or DBD::MySQL directly than to configure the unix ODBC (or Windows ODBC) support for these databases.


[]s, Fernando Lozano




More information about the fpc-pascal mailing list