python - sqlalchemy's bug in 1.0.6 and solved in 1.0.7,but happened again in 1.1.2 -


i using sqlalchemy scrapy insert database in scrapy pipeline,i use normal add this:

    album_item = hfprogramdata(**item)     try:         session.add(album_item)         session.commit()     except exception e:         print e         session.rollback()     pdid = album_item.id 

normally, know, if there no exception,then sqlalchemy change album_item, , can atrr 'id' of album_item , more, when connect mysql local, these code work fine,but when connect server of company, raise error not understand:

file "c:\python27\lib\site-packages\twisted\internet\defer.py", line 651, in _runcallbacks current.result = callback(current.result, *args, **kw)

 file "d:\workshop\xmly\xmly\pipelines.py", line 50, in process_item    albums = session.query(hfprogramdata).filter(hfprogramdata.sourceid == item['album_id']).first()   file "c:\python27\lib\site-packages\sqlalchemy\orm\query.py", line 2755, in first    ret = list(self[0:1])   file "c:\python27\lib\site-packages\sqlalchemy\orm\query.py", line 2547, in __getitem__    return list(res) 

file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 90, in instances util.raise_from_cause(err)

 file "c:\python27\lib\site-packages\sqlalchemy\util\compat.py", line 203, in raise_from_cause    reraise(type(exception), exception, tb=exc_tb, cause=cause)   file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 75, in instances    rows = [proc(row) row in fetch]   file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 437, in _instance    loaded_instance, populate_existing, populators)  file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 498, in _populate_full   dict_[key] = getter(row)  file "c:\python27\lib\site-packages\sqlalchemy\dialects\mysql\types.py", line 371, in process  in value: 

typeerror: 'int' object not iterable

i work on bug hours,but not find solution

and there more strange thing, used pycharm debug code ,sometimes work fine on line:

pdid=album_item.id 

and go wrong serveral step later

i don't know now

yesterday it's late,so leave problem today,and find sqlalchemy goes wrong,i use these easy code:

from models import session, hfprogramdata  albums = session.query(hfprogramdata).first() print len(albums) 

but there error like:

file "sqlalchemy/orm/query.py", line 2445, in first ret = list(self[0:1]) file "sqlalchemy/orm/query.py", line 2281, in getitem return list(res) file "sqlalchemy/orm/loading.py", line 84, in instances util.raise_from_cause(err) file "sqlalchemy/util/compat.py", line 199, in raise_from_cause reraise(type(exception), exception, tb=exc_tb)

so bing traceback,and find bug in 1.0.6, , fixed in 1.0.7, seems happened again in 1.1.2,so changed sqlalchemy 1.0.7, , code work fine


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -