Forum OpenACS Q&A: Re: One Script Access to Multiple PG Databases

Collapse
Posted by MaineBob OConnor on

Ok, Jeff suggested "...will have to go back to the old AOLServer api "ns_db gethandle poolname" etc)...."

Please help me with the "etc..." So far I have:

#Default database
set db [ns_db gethandle]
set selection [ns_db 0or1row $db "select user_id, first_names,
last_name from users where user_id=3"] 
set_variables_after_query
ns_db releasehandle $db

#SECOND Database
set db2  [ns_db gethandle -timeout 23 localhost:bobdata2]
set selection [ns_db 0or1row $db2 "select user_id user_id2,
first_names first_names2, last_name last_name2 from 
users where user_id=4"] 
set_variables_after_query
ns_db2 releasehandle $db

append page_content "<html>...

So, this gives me "Error: no access to pool: localhost:bobdata2

***What other things do I need to set up in THIS script to get access to the second database?

Because this is a limited an occasionally used tcl script in www, I'd like to do it here rather than in the AOLServer Startup Script.

It looks like the following are not yet set for the second db:
datasource,dbtype,driver,poolname,user,password

If these are all that are needed, please help me with the syntax in my script.

TIA

-Bob