not sure what the problem is. Pydal gets the id of the last inserted record 
from the adapter which gets it from pgsql. It does not keep its own count. 
So it is pgsql that is returning the same id.

I noticed that you have:

try: result = db.citation.validate_and_insert(**_citation) print result 
except: print db._lastsql

In general db IO inside a try except is calling for trouble. If the 
exception is cause by the database you have to rollback and cannot commit.

On Wednesday, 25 November 2015 16:06:23 UTC-6, Mark Graves wrote:
>
> Code available @
>
> https://github.com/gravesmedical/migration
>
> Its just a series of scripts that gets run in the order they are in the 
> scripts directory.
>
> -Mark
>
>
> On Sunday, November 22, 2015 at 8:58:05 PM UTC-6, Mark Graves wrote:
>>
>> Are there any caveats to know about running applications in shell mode 
>> (e.g. transactions / returning id)?
>>
>> I'm running a middleware migration script to migrate someone off an old 
>> database to a new one.
>>
>> When I run a db.table.validate_and_insert() it keeps returning me id 1.
>> This is yielding a duplicate key error understandably.
>>
>> It's like pydal and postgres are coming out of sync.
>>
>> Theres only one connection to the database, but the sequence is not being 
>> updated.
>>
>> Any thoughts?
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to