Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Initial Version and Version 1 of MultipleDatabases


Ignore:
Timestamp:
05/04/06 22:18:43 (13 years ago)
Author:
jvanasco@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MultipleDatabases

    v1 v1  
     1= Q. Can I use more than one database handle with TurboGears ? = 
     2 
     3A. You sure can!  At least with SQLalchemy 
     4 
     5== Configure your .cfg file == 
     6 
     7{{{ 
     8handle_a.sqlalchemy.dburi="postgres://database=dba&host=localhost&user=usera&password=abc" 
     9handle_b.sqlalchemy.dburi="postgres://database= dba&host=localhost&user= userb&password=xyz" 
     10}}} 
     11 
     12== Configure your model.py == 
     13 
     14{{{ 
     15engine_a = __engine_a__ = PackageEngine("handle_a") 
     16engine_b = __engine_b__ = PackageEngine("handle_b") 
     17}}} 
     18 
     19Then just instantiate tables / classes using engine_a or engine_b 
     20 
     21= What about having the same class read using one handle ( readonly slave db ) and write using another ( writing master )? = 
     22 
     23someone else will have to answer that one.  let me know when you figure it out!