so if you store record_id as a text field, ( as some plugins do like tagging ) then those ids will be wrong upon insertion to a new database.
-Thadeus On Wed, Mar 10, 2010 at 8:11 AM, mdipierro <[email protected]> wrote: > You can do it this way: > > buffer=open('buffer','wb') > db1.export_to_csv_data(buffer) > buffer=open('buffer','rb') > db2.import_from_csv_data(buffer) > > all references will be preserved although the record ids will change. > > On Mar 10, 6:24 am, Maciek Sykulski <[email protected]> wrote: >> Hi Everyone, >> >> Let's assume we have 2 databases db1, db2 with exactly the same >> structure. >> >> I need to write a function that imports all the records from db2 to >> db2 conserving appropriate structure, references on copied records. >> (of course copying records from one table to another is not good >> because of auto-incremented ids) >> >> Treatment of duplicates could be configurable, or we can assume for >> now that we always create duplicated records (as long as "unique" does >> not forbid that). >> >> I could code this to work in particular case of my particular >> database. >> Then, I thought that maybe it's worth to write a generic function, a >> plugin, that works for any given database and a set of records: >> >> def importToDb(db1, db2, list_of_tablenames, ...): # Copies records >> from all tables on the list from db2 to relevant tables in db1 >> ... >> >> Probably this function should use mechanisms which are used inside >> appadmin? >> >> I'm posting this hoping that maybe someone did something like that >> before, or maybe has some clues/ideas how to program that? >> >> Thanks, >> Maciek > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

