On Tue, Oct 28, 2008 at 06:33:01PM +0000, Matthew Wilson wrote:
> I have a special case where I need to disconnect from one database, then
> connect to another database.  After I connect to the second database, I
> want to import a different set of SQLObject classes that represent that
> database.
> 
> Finally, I want to close that connection to database #2, and then go
> back to database #1, and reload all the classes for that one.

   You don't need to disconnect - you can open as many connections as you
need. I have a program, e.g., that connects to PostgreSQL and SQLite and
copies data between them.
   Just open connections:

connection1 = connectionForURI('postgres://host:port/db')
connection2 = connectionForURI('sqlite:///path/to/db')

   and use them:

class MyTable(SQLObject):
   name = StringCol()

   Get a row from the first DB:

row1 = MyTable.get(id, connection=connection1)

   and insert the data into the second:

row2 = MyTable(**row.asDict(), connection=connection2)

   Most methods in SQLObject accept connection parameter.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to