[storm] First time raises exception; Second works.
Eduardo Willians
edujurista at gmail.com
Mon Jan 7 17:29:26 GMT 2008
PyFriends,
Im finding problems on store. Someone could help me?
>>> result = store.find(Matriculas, Matriculas.MatriculaNum.like(6)).one()
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
result = store.find(Matriculas, Matriculas.MatriculaNum.like(6)).one()
File "D:\LabSisTemporal\Routines\GeoSQL\storm\store.py", line 191, in find
self.flush()
File "D:\LabSisTemporal\Routines\GeoSQL\storm\store.py", line 438, in flush
self._flush_one(obj_info)
File "D:\LabSisTemporal\Routines\GeoSQL\storm\store.py", line 472,
in _flush_one
result = self._connection.execute(expr)
File "D:\LabSisTemporal\Routines\GeoSQL\storm\database.py", line
182, in execute
raw_cursor = self.raw_execute(statement, params)
File "D:\LabSisTemporal\Routines\GeoSQL\storm\database.py", line
242, in raw_execute
raw_cursor.execute(statement)
File "C:\Python25\lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line
35, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1364, "Field 'Nome' doesn't have a default value")
>>>
>>> # Look. I'll try the same line but now it will work
>>> result = store.find(Matriculas, Matriculas.MatriculaNum.like(6)).one()
>>> result.Nome
u'Edson da Rocha Raimundo'
>>>
For some reason, this problem looks to happen only on that table. So
here is the table class code:
<code>
class Matriculas(object):
__storm_table__ = "matriculas"
MatriculaNum = Int(primary=True)
Nome = Unicode()
Identificacao = Unicode(name="Id") # TODO: Change name in DB
Funcao = Unicode()
NivelAcesso = Int()
Pw = RawStr()
</code>
To solve the problem I have to use this:
<code>
try:
result = store.find(Matriculas, Matriculas.MatriculaNum.like(login))
matric = result.one()
except:
# I dont why: at first store.find runnig on 'Matriculas' it
# raises an exception. But at second it works fine.
result = store.find(Matriculas, Matriculas.MatriculaNum.like(login))
matric = result.one()
</code>
Sorry for my poor english.
Thanks anyway,
EduardoWillians
More information about the storm
mailing list