Solved!

Thanks again for your help.  yes, I had the db's defined in the model. 
 But, they *weren't* quite identical.  AND, I wanted to get the id from the 
"old" table because I will be using it later after I've munged the rest of 
the record--to update the original record in the original table.  I am 
using the new table as a batch update--after the changes are accumulated, 
then I will update the original table.

To break down what was happening,  I decided to purge the "funny" things 
from the rows object (1 record from the old table):  the two lambda 
functions and a foreign key and then I just inserted a single field value 
into the new table to see if that would work.   And that showed me the 
error of my ways--it worked, so the problem had nothing to do with 
postgresql failing to increment the integer index (which is sort of what 
the error message implied...).

What I was stupidly doing was trying to write over the 'id' field of the 
new table with the 'id' field of the old table.   Naturally, postgresql was 
unhappy since the id field is an auto-increment field.

Now, in the "new" table I created a field called 'oldid' to hold the key 
value (old.id) from the old table so I don't try to tromp on the new 
table's 'id' field.  I don't actually care what the values of the new 
table's id are--I'll never use them.  But, I do need to keep the old key 
(oldid) around to later update the right records in the original table.

Doh!   Sorry for being so cranky!  But, rows objects are a bit funky--I'll 
try to think of ways they might be easier.  The real problem showed up as 
an unusual error message, but it was totally because I was doing something 
DUMB.

On Monday, April 16, 2012 8:28:52 PM UTC-7, pbreit wrote:
>
> Doubt this is the problem but your code doesn't look right to me. Did you 
> say you were trying to move a record from one db into an identical table in 
> another db? SO would expect to see something like:
>
> db1 = DAL(...
> db2 = DAL(...
>
> row = db1.joke(jokenum)
> db2.joke.insert(**row.as_dict())
>

Reply via email to