Index: openacs-4/packages/acs-core-docs/www/tutorial-second-database.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/tutorial-second-database.html,v diff -u -N -r1.2.2.1 -r1.2.2.2 --- openacs-4/packages/acs-core-docs/www/tutorial-second-database.html 26 Aug 2005 00:02:30 -0000 1.2.2.1 +++ openacs-4/packages/acs-core-docs/www/tutorial-second-database.html 9 Apr 2006 22:26:18 -0000 1.2.2.2 @@ -1,13 +1,14 @@ -
It is possible to use the OpenACS TCL database API with + +
It is possible to use the OpenACS TCL database API with other databases. In this example, the OpenACS site uses a PostGre database, and accesses another PostGre database called legacy.
Modify config.tcl to accomodate the legacy database, and to ensure that the legacy database is not used for standard OpenACS queries:
ns_section ns/db/pools
-ns_param pool1 "Pool 1"
-ns_param pool2 "Pool 2"
-ns_param pool3 "Pool 3"
-ns_param legacy "Legacy"
+ns_param pool1 "Pool 1"
+ns_param pool2 "Pool 2"
+ns_param pool3 "Pool 3"
+ns_param legacy "Legacy"
ns_section ns/db/pool/pool1
#Unchanged from default
@@ -17,7 +18,7 @@
ns_param verbose $debug
ns_param extendedtableinfo true
ns_param logsqlerrors $debug
-if { $database == "oracle" } {
+if { $database == "oracle" } {
ns_param driver ora8
ns_param datasource {}
ns_param user $db_name
@@ -26,7 +27,7 @@
ns_param driver postgres
ns_param datasource ${db_host}:${db_port}:${db_name}
ns_param user $db_user
- ns_param password ""
+ ns_param password ""
}
ns_section ns/db/pool/pool2
@@ -56,13 +57,13 @@
ns_param database_names [list main legacy]
ns_param pools_main [list pool1 pool2 pool3]
ns_param pools_legacy [list legacy]
To use the legacy database, use the
- -dbn
flag for any of the
- db_
API calls. For
- example, suppose there is a table called "foo" in the legacy
- system, with a field "bar". List "bar" for all records with
+ -dbn flag for any of the
+ db_ API calls. For
+ example, suppose there is a table called "foo" in the legacy
+ system, with a field "bar". List "bar" for all records with
this tcl file:
db_foreach -dbn legacy get_bar_query { select bar from foo limit 10 } { - ns_write "<br/>$bar" + ns_write "<br/>$bar" }