On 4/5/15 12:54 AM, biohege...@gmail.com wrote: > Thanks for your input! It helped my to find a bug in my code. > I inserted 0 for false, 1 and 2 for true. > > However, inserting a "bad" value for boolean using SQLAlchemy should > also result in an exception and not only selecting a boolean with a > "bad" value.
The Boolean type does this by using a CHECK constraint. Your database was probably built by some other means than using SQLAlchemy's schema system so the CHECK constraint is missing. If you'd like a Python-side check you can use a TypeDecorator around Boolean to verify the values coming in. > > Thanks again, > Tamas > > On Saturday, April 4, 2015 at 5:27:28 PM UTC+2, biohe...@gmail.com wrote: > > Hi, > > I get a strange error when querying a many-to-many relationship > (Protein - Omim / protein - omim). > sqlalchemy 0.9.9 > > o=Omim.query.filter(Omim.acc=="157140").one() # this is OK > o.proteins # this gives an error > > 2015-04-04 17:16:09,984 INFO sqlalchemy.engine.base.Engine SELECT > protein.id <http://protein.id> AS protein_id, protein.acc AS > protein_acc, protein.entry_name AS protein_entry_name, > protein.gene_name AS protein_gene_name, protein.is_human AS > protein_is_human, protein.is_membrane AS protein_is_membrane, > protein.is_reviewed AS protein_is_reviewed, protein.sprot_str AS > protein_sprot_str > FROM protein, omim_assoc > WHERE %s = omim_assoc.omim_id AND protein.id <http://protein.id> = > omim_assoc.protein_id > 2015-04-04 17:16:09,985 INFO sqlalchemy.engine.base.Engine (16083L,) > Traceback (most recent call last): > [skipped] > File > > "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/strategies.py", > line 169, in fetch_col > dict_[key] = row[col] > ValueError: int_to_boolean only accepts None, 0 or 1 > > ---- > However, when querying this in mysql client: > SELECT protein.id <http://protein.id> AS protein_id FROM protein, > omim_assoc WHERE 16083 = omim_assoc.omim_id AND protein.id > <http://protein.id> = omim_assoc.protein_id; > No problem, the protein is found. > > Moreover, if I query Omim with a different ac, it works. > > ---- > I have no idea how to debug... > > Thanks for your help in advance, > Tamas > > -- > 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 > <mailto:sqlalchemy+unsubscr...@googlegroups.com>. > To post to this group, send email to sqlalchemy@googlegroups.com > <mailto:sqlalchemy@googlegroups.com>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- 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/d/optout.