Hi all,

I have a custom migration script that connects to two different databases and
transfers data from one to the other, adapting it to the new structure and
format.

On the source side it uses the autoloading feature of a Table, while on the
target each table is fully described, and some of the fields use custom
TypeDecorators (for example something very similar to the platform indipendent
GUID type described in the recipes on the SA website).

It basically executes something like the following (omitting details like
transactions and errors handling):

  old_table = Table("name", old_metadata, autoload=True")
  query = select([old_table])
  insert = new_table.insert()
  result = old_connection.execute(query)
  for old_row in result:
      new_row = adapt(old_row)
      new_connection.execute(insert, new_row)

where "adapt()" is a function specific to the particular table that can
manipulate the content of each field.

With the approach above custom column types used by the "new_table" are not
playing their "magic", and I currently must repeat it within the "adapt()"
function.

Is there any alternative approach, or maybe a way to run the equivalent code
path that SA executes when doing an insert using its ORM layer, so that I can
simplify the "adapt()" function applying the DRY principle?

Thank you in advance for any hints,
bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  |                 -- Fortunato Depero, 1929.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to