[storm] .get/find Triggers sqlite3.IntegrityError
Abel, John
John.Abel at bbusl.com
Mon Mar 16 15:17:29 GMT 2009
Hi,
I'm just getting to grips with Storm, so I apologise if this is an error
on my part.
I have an loop, which calls a function, passing a two dict objects. I
was trying to code the function so that it would handle new records, as
well as modifying existing records. To do this, I was carrying out a
find ( though I have tried get, as well ). If None was returned, I was
creating a new object. If an object was found, it was ( hopefully )
returned, so I could update it. However, when find/get is issued with a
ID that exists, I'm encountering an sqlite3.IntegrityError, as seen
below. Is there something I'm doing wrong?
The function code is:
def insert( self, data, updateDesc ):
newObj = self._dbConn.find( Asset, Asset.assetID == int( data[
'assetID' ] ) ).one()
if newObj is None:
newObj = Asset()
newObj = int( data[ 'assetID' ] )
self._dbConn.add( newObj )
newObj.assetDesc = updateDesc
self._dbConn.flush
return newObj
The trackback is:
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/store.py", line 206, in find
self.flush()
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/store.py", line 486, in flush
self._flush_one(obj_info)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/store.py", line 523, in _flush_one
result = self._connection.execute(expr)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/database.py", line 203, in execute
raw_cursor = self.raw_execute(statement, params)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/databases/sqlite.py", line 153, in raw_execute
return Connection.raw_execute(self, statement, params)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/database.py", line 284, in raw_execute
self._check_disconnect(raw_cursor.execute, *args)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa
ckages/storm/database.py", line 325, in _check_disconnect
return function(*args, **kwargs)
sqlite3.IntegrityError: PRIMARY KEY must be unique
I'm using Python 2.6.1/Storm 0.14 on OSX 10.5.6. Any pointers would be
much appreciated.
Thanks
John
This email may contain information which is confidential and is intended only for use of the recipient/s named above. If you are not an intended recipient, you are hereby notified that any copying, distribution, disclosure, reliance upon or other use of the contents of this email is strictly prohibited. If you have received this email in error, please notify the sender and destroy it. "Think before you Print-please do not print this email unless you really need to" Balfour Beatty plc is registered in England as a public limited company; Registered No: 395826; Registered Office: 130 Wilton Road, London, SW1V 1LQ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/storm/attachments/20090316/6f579a79/attachment.htm
More information about the storm
mailing list