On Feb 19, 2014, at 1:28 PM, a...@bitcredits.io wrote:

> Hi there,
> 
> I've been hitting an intermittent bug with SQLAlchemy/PostgreSQL using an 
> HSTORE column.  Some times, when I restart my process (pyramid over gevent 
> over chaussette), I get a spew of such errors... some other time, everything 
> goes just fine.
> 
> It seems this bug hasn't been documented anywhere, or at least the error I 
> get wasn't reported.
> 
> If you guys have any insight at all that would help me out in my search for 
> the bug, I'd be eternally grateful.  Here is the traceback:

if you’re on 0.8.4 or any 0.9, there is a bug fix going out today that is very 
likely part of this, has to do with the engine determining if HSTORE support is 
turned on.

Assuming this is your issue, a workaround would be:

eng = create_engine(…)

conn = eng.connect()
conn.close()

before any other use of that engine occurs.  this will ensure that the correct 
info about HSTORE is determined up front.






> 
>   File "/home/abourget/build/bitc/Bitc/bitc/api.py", line 126, in 
> website_from_origin
>     website = Website.get_by_host(origin)
>   File "/home/abourget/build/bitc/Bitc/bitc/models.py", line 299, in 
> get_by_host
>     Website.deleted == False).first()
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
>  line 2320, in first
>     ret = list(self[0:1])
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
>  line 2187, in __getitem__
>     return list(res)
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
>  line 72, in instances
>     rows = [process[0](row, None) for row in fetch]
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
>  line 451, in _instance
>     populate_state(state, dict_, row, isnew, only_load_props)
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
>  line 305, in populate_state
>     populator(state, dict_, row)
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/orm/strategies.py",
>  line 154, in fetch_col
>     dict_[key] = row[col]
>   File 
> "/home/abourget/build/bitc/env/local/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.py",
>  line 291, in process
>     return _parse_hstore(value.decode(encoding))
> AttributeError: 'dict' object has no attribute 'decode'
> 
> Just for little context, models.py:299 in full is:
>         website = db.query(Website).filter(Website.domain == host,
>                                             Website.deleted == False).first()
> 
> There is one field on Website, declared as such:
> 
>     data_apis = Column(MutableDict.as_mutable(HSTORE), default=dict)
> 
> perhaps that last default=dict would induce such a problem ?  I'll try 
> investigating that path.
> 
> thanks for any help!
> 
> Alexandre
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to