Title: DB Example
I am using the following in the db area in the config.tcl:
#
# Database drivers
#
# The database driver is specified here (it is loaded by nspostgres.so).
# postgresql is used as an example.
ns_section "ns/db/drivers"
ns_param postgres nspostgres.so ;# Use nspostgres.so for an external
driver
ns_param defaultpool mypool ;# Optionally specify default pool
ns_param pools mypool ;# Optionally specify list of pools
# Specify the name of the database pool here.
ns_section "ns/db/pools"
ns_param mypool "This pool is for the Postgres driver"
# Describe the pool in detail here. This section depends on the db driver.
ns_section "ns/db/pool/mypool"
ns_param driver postgres ;# From "ns/db/drivers" list
ns_param datasource "localhost:5432:postgres" ;# Not for nssybpd
ns_param user username ;# Username for database
ns_param password userpass ;# Password for database
ns_param connections 1 ;# No. of connections to open
ns_param logsqlerrors true ;# Verbose SQL query error logging
ns_param maxidle 600 ;# Max time to keep idle db conn open
ns_param maxopen 3600 ;# Max time to keep active db conn open
ns_param verbose true ;# Verbose error logging
# Tell the virtual server about the pools it can use.
ns_section "ns/server/${servername}/db"
ns_param pools *
And I am using this code from the aolserver examples:
DB Example
Select a db table from the default db pool:
<%
set db [ns_db gethandle]
set sql "select * from tables"
set row [ns_db select $db $sql]
while {[ns_db getrow $db $row]} {
set table [ns_set get $row name]
ns_puts "$table"
}
%>
and when I run the page on the server I get the no defaultpool error on the
aolserver console log.
Also I ran select * from tables in psql and it gave me a syntax error. How
would I determine all the tables in a database?
thanks,
wes