[AOLSERVER] using openacs db api

10 views
Skip to first unread message

Xavier Bourguignon

unread,
Apr 2, 2008, 3:49:20 PM4/2/08
to AOLS...@listserv.aol.com
Hi All,

Does anybody know what is required to use "OpenAcs DB API" for
accessing Postgres DB within aolserver?

Thank you

--
Xavier Bourguignon


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

Dave Bauer

unread,
Apr 2, 2008, 4:23:22 PM4/2/08
to AOLS...@listserv.aol.com
You'd have to 1) Install OpenACS http://openacs.org/
or 2) try to extract the database api procedures in
http://cvs.openacs.org/cvs/openacs-4/packages/acs-tcl/tcl/
00-database-procs.tcl
00-database-procs-postgresql.tcl
00-database-procs-oracle.tcl
and take the queries out of the XML files
00-database-procs-postgresql-postgresql.xql into the tcl library file
(due to datbase abstraction technique specific to OpenACS.)

The code relies on a configuration param in your AOLserver config file also see
return [nsv_get ad_database_type .] where there is an nsv variable
set on startup to decide oracle or postgresql.

This was just a quick review there might be other stuff you will need
to make it work.
OpenACS also has automatic database handle handling (sorry couldn't
think of a better word for that.)

This contains the postgresql bind variable emulation implementation as
well that replaces tcl variables in the query string.

Here is an overview of how the database api works.
http://openacs.org/doc/current/db-api.html

Dave

--
Dave Bauer
da...@solutiongrove.com
http://www.solutiongrove.com

Jeff Rogers

unread,
Apr 2, 2008, 5:06:49 PM4/2/08
to AOLS...@listserv.aol.com
Xavier Bourguignon wrote:
> Hi All,
>
> Does anybody know what is required to use "OpenAcs DB API" for
> accessing Postgres DB within aolserver?

OpenACS is a complete integrated platform for creating web communities;
I suspect that the DB api builds on the ACS core api and as such it is
not a trivial matter to use the former without the latter. If you're
building a new community system, OpenACS is worth a look, but it's a
large system to just jump into (especially as an intro to aolserver,
tcl, or both).

http://openacs.org/ - OpenACS home
http://openacs.org/doc/current/db-api.html - docs on the ACS db api

That said, it's not difficult to emulate some of the useful things like
bind variables. This proc expands ? in sql statements. It could easily
be made to call ns_dbquotevalue before replacing the variables. It does
not do anything with the db drivers, so it is of no help for something
like bypassing oracle's 4000 character limit as native bind variables do.

proc bindsql {sql args} {
set varcount [llength $args]
set indices [regexp -all -indices -inline {\?} $sql]
if {[llength $indices] != $varcount} {
error "[llength $indices] variables expected, $varcount passed"
}
set ofs 0
foreach replacement $args idx $indices {
set ix [expr {[lindex $idx 0]+$ofs}]
set sql [string replace $sql $ix $ix $replacement]
incr ofs [string length $replacement]
incr ofs -1
}
return $sql
}

set adminop_sql {select * from tadminop where status = ?}
ns_db select $db [bindsql $adminop_sql 'a']

-J

Juan José del Río (Simple Option)

unread,
Apr 2, 2008, 4:12:24 PM4/2/08
to AOLS...@listserv.aol.com
I think I do... It's called OpenACS :)


On Wed, 2008-04-02 at 20:49 +0100, Xavier Bourguignon wrote:
> Hi All,
>
> Does anybody know what is required to use "OpenAcs DB API" for
> accessing Postgres DB within aolserver?
>
> Thank you
>


--

Xavier Bourguignon

unread,
Apr 3, 2008, 2:14:00 PM4/3/08
to AOLS...@listserv.aol.com
thank you all for the info.

Jeff, I have been using your code and adapted it to my needs, thanks for that.

On 02/04/2008, Juan José del Río (Simple Option)


--
Xavier Bourguignon

Reply all
Reply to author
Forward
0 new messages