You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Bob Rossi <bo...@cox.net> on 2007/11/29 22:43:44 UTC

database independent connections

Hi,

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?

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

Thanks,
Bob Rossi

Re: database independent connections

Posted by Bob Rossi <bo...@cox.net>.
On Fri, Nov 30, 2007 at 12:12:16PM +1100, Bojan Smojver wrote:
> On Thu, 2007-11-29 at 17:34 -0500, Bob Rossi wrote:
> 
> > OK, perhaps we could have some high level documentation on the webpage
> > for the dbd documentation that describes which databases it works with?
> 
> http://apr.apache.org/docs/apr-util/1.2/group___a_p_r___util___d_b_d.html#geff12b01f78ac78721acc4a0a318e673
> http://apr.apache.org/docs/apr-util/trunk/group___a_p_r___util___d_b_d.html#gbddb1fdcb2f8a5f5b83127485c78e8ae

Aha! I would suggest that a summary for each package goes at the top of
each file in the documentation.

Thanks for all the great work.

Bob Rossi

Re: database independent connections

Posted by Bojan Smojver <bo...@rexursive.com>.
On Thu, 2007-11-29 at 17:34 -0500, Bob Rossi wrote:

> OK, perhaps we could have some high level documentation on the webpage
> for the dbd documentation that describes which databases it works with?

http://apr.apache.org/docs/apr-util/1.2/group___a_p_r___util___d_b_d.html#geff12b01f78ac78721acc4a0a318e673
http://apr.apache.org/docs/apr-util/trunk/group___a_p_r___util___d_b_d.html#gbddb1fdcb2f8a5f5b83127485c78e8ae

-- 
Bojan


Re: database independent connections

Posted by Bob Rossi <bo...@cox.net>.
On Fri, Nov 30, 2007 at 09:21:56AM +1100, Bojan Smojver wrote:
> 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.

You know, this is exactly what i want and hoped for. Sometimes I just
love this open source stuff...

> > 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.

OK, perhaps we could have some high level documentation on the webpage
for the dbd documentation that describes which databases it works with?

Thanks,
Bob Rossi

Re: database independent connections

Posted by Bojan Smojver <bo...@rexursive.com>.
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