On Tue, Feb 05, 2008 at 10:27:05PM +0100, Petr Jake?? wrote:
> So you mean it is OK to crate table object using:
> 
> db_filename = 'c|\\Program
> Files\\Firebird\\Firebird_2_0\\examples\\empbuild\\automat.fdb'
> connection_string = 'firebird://127.0.0.1:3050/' + db_filename
> connection = connectionForURI(connection_string)
> sqlhub.processConnection = connection
> 
> connection2 = connectionForURI('sqlite:///work/mincovnik.db')
> 
> and than creating tables like:
> 
>    - MyTable1.createTable(ifNotExists=True)
>    I mean: if not definning the connection, tables will be creted using
>    connection from the sqlhub
> 
>    - MyTable2.createTable(ifNotExists=True, connection=connection2)
>    I mean: if connection is defined, than the table will be created using
>    specified connection

   Yes. And you don't need to redecalre tables - if MyTable and MyTable2
are realy the same table - just do

MyTable.createTable(ifNotExists=True, connection=connection2)

> And after that, it is not necessary to take care about the connection in the
> rest of the code?

   No, after that there are many different calls to pass connection2 to. Of
course if MyTable and MyTable2 are really two different tables and every
one of them are in two different databases you just set connection2 to be
the default connection for MyTable2:

MyTable2.setConnection(connection2)

   and forget about connections. But if you want to copy data between two
identical tables in two different databases - you have to pass connection2
to all methods you call:

for row in MyTable.select(connection=connection2):
   new_row = MyTable(**row.asDict())

   The loop draws row from the second DB and inserts them into the first
DB. To do this in the opposite directtion:

for row in MyTable.select():
   new_row = MyTable(connection=connection2, **row.asDict())

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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to