apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bojan Smojver <bo...@rexursive.com>
Subject Re: database independent connections
Date Thu, 29 Nov 2007 22:21:56 GMT
On Thu, 2007-11-29 at 16:43 -0500, Bob Rossi wrote:

> I'm a newb with database connections, so forgive me if this is a simple
> question. I'm looking into using the dbd routines to open connections 
> to a database. The routines are here,
>   http://apr.apache.org/docs/apr-util/1.2/group___a_p_r___util___d_b_d.html
> 
> I want to know if this interface allows me to easily swap out the
> underlying database so I don't get stuck using a particular database.
> Say perhaps, could the same code use mysql, oracle or db2?
> Also, how does sqlite play into it?

MySQL, yes. Oracle, only with trunk (i.e. unreleased version 1.3 of
APU). DB2, no (feel free to contribute the driver! :-). SQLite 2 and 3,
yes.

Yes, APU DBD is an abstraction layer on top of native database APIs, so
you should be able to use the same code with different databases,
provided that SQL you pump in is supported by databases in question.

> I'm looking for high level advice on how to design software that needs
> to open connections from different sources using the apr API.

You can have a look at the source of mod_dbd of Apache, for instance.

For a quick a dirty intro, look at the test/testdbd.c program in the
tarball of APU.

-- 
Bojan


Mime
View raw message