Hello list,

Using SA 0.2.4, I'm getting a ConcurrencyError and I don't know how to
resolve it.  I'm getting data from a CSV file one line at a time and
updating objects mapped to a postgres table.  Most of the data updates
fine, just certain lines seem to be causing issues.  The __dict__ of
the object I'm trying to update (after updating with new data) is:

{'_AttributeManager__sa_attr_state': {'modified': True,
                                      'original': CommittedState:
{'modified_date': None, 'modified_by': None, 'syear': Decimal("2005"),
'end_date': datetime.date(2005, 8, 22), 'student_id':
Decimal("120270089"), 'start_date': datetime.date(2004, 8, 20),
'school_id': Decimal("1"), 'scheduler_lock': None, 'mp': None,
'course_period_id': Decimal("3115"), 'course_id': Decimal("678"),
'marking_period_id': None, 'id': Decimal("133"), 'course_weight':
'Zero'}},
 '_Schedule__sa_attr_state': {},
 '_entity_name': None,
 '_instance_key': (<class 'database.Schedule'>,
                   (Decimal("2005"),
                    Decimal("120270089"),
                    Decimal("678"),
                    'Zero',
                    Decimal("3115"),
                    datetime.date(2004, 8, 20)),
                   None),
 '_sa_session_id': 14308368,
 'course_id': Decimal("678"),
 'course_period_id': Decimal("3115"),
 'course_weight': 'Zero',
 'end_date': '08/22/2005',
 'id': Decimal("133"),
 'marking_period_id': None,
 'modified_by': None,
 'modified_date': None,
 'mp': None,
 'scheduler_lock': None,
 'school_id': Decimal("1"),
 'start_date': '08/22/2005',
 'student_id': Decimal("120270089"),
 'syear': Decimal("2005")}


This is what I get with echo_uow=True (nothing to see here, really.):

Task dump:

 UOWTask(15073328, Schedule/schedule/None)
  |- Save Schedule(15073584)
  |----


And finally, the exception raised:

FlushError: ConcurrencyError - updated rowcount 0 does not match
number of objects updated 1
Traceback:
  File "<string>", line 1, in ?
  File "c:\Python24\projects\basejumper\APSCNparser.py", line 636, in ?
    session.flush()
  File "C:\Python24\lib\site-packages\sqlalchemy\orm\session.py", line
233, in flush
    self.uow.flush(self, objects, echo=self.echo_uow)
  File "C:\Python24\lib\site-packages\sqlalchemy\orm\unitofwork.py",
line 228, in flush
    flush_context.execute(echo=echo)
  File "C:\Python24\lib\site-packages\sqlalchemy\orm\unitofwork.py",
line 399, in execute
    head.execute(self)
  File "C:\Python24\lib\site-packages\sqlalchemy\orm\unitofwork.py",
line 667, in execute
    self._save_objects(trans)
  File "C:\Python24\lib\site-packages\sqlalchemy\orm\unitofwork.py",
line 621, in _save_objects
    task.mapper.save_obj(task.tosave_objects, trans)
  File "C:\Python24\lib\site-packages\sqlalchemy\orm\mapper.py", line
808, in save_obj
    raise exceptions.FlushError("ConcurrencyError - updated rowcount
%d does not match number of objects updated %d" % (rows, len(update)))


it seems like every one of the ones having errors shows in the
_instance_key attribute a date of 2004-8-20, that doesn't match
anything I'm giving to the object.  How do I go about finding the
problem?

Brian

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to