On Tue, Aug 21, 2012 at 7:18 AM, Alan Etkin <spame...@gmail.com> wrote:
> El lunes, 20 de agosto de 2012 21:04:46 UTC-3, Alexei Vinidiktov escribió: > >> This web2py group thread may be of help: >> >> https://groups.google.com/**forum/?fromgroups=#!topic/** >> web2py/0X3ykXLmcEQ<https://groups.google.com/forum/?fromgroups=#%21topic/web2py/0X3ykXLmcEQ> >> >> >> Also see issue: >> http://code.google.com/p/**web2py/issues/detail?id=796<http://code.google.com/p/web2py/issues/detail?id=796> >> If >> I understand it correctly, it has been implemented in trunk. >> >> > So re-editing import_csv_.. does not seem the way to go. Would you think > that It's possible to call import_... with id_map={} for a clean pg > database to keep old ids? > > As far as I understand id_map={} only allows you to maintain referential integrity but it doesn't present the original ids. Whereas the solution proposed in issue http://code.google.com/p/** web2py/issues/detail?id=796<http://code.google.com/p/web2py/issues/detail?id=796> should allow to preserve the original ids. Quote: " PostgreSQL: ...import rows... count = db.executesql('SELECT MAX(id) FROM mytable;') count += 1 db.executesql('ALTER SEQUENCE mytable_sequence RESTART WITH %s;' % count) MySQL and PostgreSQL should both let you insert manual ID values. You just have to reset the auto-increment value so that new rows after import get proper IDs. With MSSQL, you have to do the import as a transaction, turning on the ability to manually insert ID values, then importing, and finally telling it to automatically recalculate the auto-increment values. " I haven't tried it myself though. In the issue tracker issue 796 is marked as fixed, but there is no explanation of how it was fixed. I hope Massimo will chime in. -- Alexei Vinidiktov --