Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
Great help. Thanks. On Saturday, April 30, 2011, Michael Bayer wrote: > the docs for 0.6: > http://www.sqlalchemy.org/docs/ > and the session bind thing you can see some info about: > http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.sessionmaker > > On Apr 30, 2011, at 12:40 PM, Mihir Sevak wrote: > It is a different version of Sqlalchemy. > Also the project is written in Pylons so we are upgrading that which requries > SQLAlchemy 0.6.x. > > Is there some book or reading material you can point me to pleas?? > > Thanks. > > On Sat, Apr 30, 2011 at 12:36 PM, Michael Bayer > wrote: > > this has to do with how the Session is configured and if its linked to an > engine. > Curious, the "upgrade" happening here is strictly because a newer version of > Debian has a different version of SQLAlchemy ? It would be really, really > preferable if you could run the specific version of SQLAlchemy the app was > written against, we change the API with each 0.x version. This does > however mean you'd need to install SQLAlchemy using standard Python > setuptools methodologies and not via a deb package. The effort you're > making here would be towards porting the app to 0.5.8 based on your trace > below...we're already up to 0.7. With a straight install, it only means > SQLAlchemy would be installed under "site-packages" instead of > "dist-packages". > > > On Apr 29, 2011, at 8:54 PM, Mihir Sevak wrote: > Actually to be specific I am getting following error now > > > Errorlog > * > File '/home/mihir/development/web/web/controllers/real.py', line 187 in search > total_matches = matching_products.count() > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', > line 1552 in count > should_nest = should_nest[0] > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', > line 1583 in _col_aggregate > return self.session.scalar(s, params=self._params, > mapper=self._mapper_zero()) > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 758 in scalar > return self.execute(clause, params=params, mapper=mapper, **kw).scalar() > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 750 in execute > engine = self.get_bind(mapper, clause=clause, **kw) > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 888 in get_bind > ', '.join(context))) > UnboundExecutionError: Could not locate a bind configured on mapper > Mapper|Product|products, SQL expression or this Session > > *** > > On Fri, Apr 29, 2011 at 8:32 PM, Mihir Sevak wrote: > > > > Hi Mike thanks very much for taking time to respond to my question. > > After taking the alias away it stopped complaining about that perticular > line. But the function which was calling this function did not get query > results. So tried to print "q" itself and it was the query-line itself instead > of results. > > Something like > > "SELECT xXXX DESC" > > Is there some change in the way to read the results from "q" object? > Because I have not changed a single letter of the code and what work > on other platform doesn't work here. So i am confused. > > > Thanks for your help. > > On Fri, Apr 29, 2011 at 8:13 PM, Michael Bayer > wrote: > > > On Apr 29, 2011, at 1:55 PM, Mihir wrote: > >> @classmethod >> def fulltext_adv(cls, search_string, raw_search=''): >> q = Session.query(cls) >> text_query = func.to_tsquery(search_string).alias('query') >> q = q.filter(cls.tsv.op('@@')(text_query)) > > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- "How can anything be impossible when impossible itself says I M Possible???" Mihir -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
the docs for 0.6: http://www.sqlalchemy.org/docs/ and the session bind thing you can see some info about: http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.sessionmaker On Apr 30, 2011, at 12:40 PM, Mihir Sevak wrote: > It is a different version of Sqlalchemy. > Also the project is written in Pylons so we are upgrading that which requries > SQLAlchemy 0.6.x. > > Is there some book or reading material you can point me to pleas?? > > Thanks. > > On Sat, Apr 30, 2011 at 12:36 PM, Michael Bayer > wrote: > this has to do with how the Session is configured and if its linked to an > engine. > > Curious, the "upgrade" happening here is strictly because a newer version of > Debian has a different version of SQLAlchemy ?It would be really, really > preferable if you could run the specific version of SQLAlchemy the app was > written against, we change the API with each 0.x version.This does > however mean you'd need to install SQLAlchemy using standard Python > setuptools methodologies and not via a deb package.The effort you're > making here would be towards porting the app to 0.5.8 based on your trace > below...we're already up to 0.7. With a straight install, it only means > SQLAlchemy would be installed under "site-packages" instead of > "dist-packages". > > > On Apr 29, 2011, at 8:54 PM, Mihir Sevak wrote: > >> Actually to be specific I am getting following error now >> >> >> Errorlog >> * >> File '/home/mihir/development/web/web/controllers/real.py', line 187 in >> search >> total_matches = matching_products.count() >> File >> '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', >> line 1552 in count >> should_nest = should_nest[0] >> File >> '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', >> line 1583 in _col_aggregate >> return self.session.scalar(s, params=self._params, >> mapper=self._mapper_zero()) >> File >> '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', >> line 758 in scalar >> return self.execute(clause, params=params, mapper=mapper, **kw).scalar() >> File >> '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', >> line 750 in execute >> engine = self.get_bind(mapper, clause=clause, **kw) >> File >> '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', >> line 888 in get_bind >> ', '.join(context))) >> UnboundExecutionError: Could not locate a bind configured on mapper >> Mapper|Product|products, SQL expression or this Session >> >> *** >> >> On Fri, Apr 29, 2011 at 8:32 PM, Mihir Sevak wrote: >> Hi Mike thanks very much for taking time to respond to my question. >> >> After taking the alias away it stopped complaining about that perticular >> line. But the function which was calling this function did not get query >> results. So tried to print "q" itself and it was the query-line itself >> instead >> of results. >> >> Something like >> >> "SELECT xXXX DESC" >> >> Is there some change in the way to read the results from "q" object? >> Because I have not changed a single letter of the code and what work >> on other platform doesn't work here. So i am confused. >> >> >> Thanks for your help. >> >> >> On Fri, Apr 29, 2011 at 8:13 PM, Michael Bayer >> wrote: >> >> On Apr 29, 2011, at 1:55 PM, Mihir wrote: >> >> > @classmethod >> >def fulltext_adv(cls, search_string, raw_search=''): >> >q = Session.query(cls) >> >text_query = func.to_tsquery(search_string).alias('query') >> >q = q.filter(cls.tsv.op('@@')(text_query)) >> >if raw_search: >> >q = q.order_by(Product.name.op('ilike')(raw_search + >> > '%').desc()) >> >q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, >> > sa.literal_column('query'), 1))) >> >return q >> > >> > AttributeError: Element to_tsquery(:to_tsquery_1) does not support >> > 'as_scalar()' >> >> you probably don't want to call "alias('query')" on the func.to_tsquery() >> object. that turns it into an aliased SELECT construct that isn't >> particularly appropriate to pass to an operator ('@@' above). >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to sqlalchemy@googlegroups.com. >> To unsubscribe from this group, send email to >> sqlalchemy+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/sqlalchemy?hl=en. >> >> >> >> >> -- >> "How can anything be impossible when impossible itself says I M Possible???" >> Mihir >> >> >> >> -- >> "How can anything be impossible
Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
It is a different version of Sqlalchemy. Also the project is written in Pylons so we are upgrading that which requries SQLAlchemy 0.6.x. Is there some book or reading material you can point me to pleas?? Thanks. On Sat, Apr 30, 2011 at 12:36 PM, Michael Bayer wrote: > this has to do with how the Session is configured and if its linked to an > engine. > > Curious, the "upgrade" happening here is strictly because a newer version > of Debian has a different version of SQLAlchemy ?It would be really, > really preferable if you could run the specific version of SQLAlchemy the > app was written against, we change the API with each 0.x version.This > does however mean you'd need to install SQLAlchemy using standard Python > setuptools methodologies and not via a deb package.The effort you're > making here would be towards porting the app to 0.5.8 based on your trace > below...we're already up to 0.7. With a straight install, it only means > SQLAlchemy would be installed under "site-packages" instead of > "dist-packages". > > > On Apr 29, 2011, at 8:54 PM, Mihir Sevak wrote: > > Actually to be specific I am getting following error now > > > Errorlog > > * > File '/home/mihir/development/web/web/controllers/real.py', line 187 in > search > total_matches = matching_products.count() > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', > line 1552 in count > should_nest = should_nest[0] > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', > line 1583 in _col_aggregate > return self.session.scalar(s, params=self._params, > mapper=self._mapper_zero()) > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 758 in scalar > return self.execute(clause, params=params, mapper=mapper, **kw).scalar() > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 750 in execute > engine = self.get_bind(mapper, clause=clause, **kw) > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 888 in get_bind > ', '.join(context))) > UnboundExecutionError: Could not locate a bind configured on mapper > Mapper|Product|products, SQL expression or this Session > > > *** > > On Fri, Apr 29, 2011 at 8:32 PM, Mihir Sevak wrote: > >> Hi Mike thanks very much for taking time to respond to my question. >> >> After taking the alias away it stopped complaining about that perticular >> line. But the function which was calling this function did not get query >> results. So tried to print "q" itself and it was the query-line itself >> instead >> of results. >> >> Something like >> >> "SELECT xXXX DESC" >> >> Is there some change in the way to read the results from "q" object? >> Because I have not changed a single letter of the code and what work >> on other platform doesn't work here. So i am confused. >> >> >> Thanks for your help. >> >> >> On Fri, Apr 29, 2011 at 8:13 PM, Michael Bayer >> wrote: >> >>> >>> On Apr 29, 2011, at 1:55 PM, Mihir wrote: >>> >>> > @classmethod >>> >def fulltext_adv(cls, search_string, raw_search=''): >>> >q = Session.query(cls) >>> >text_query = func.to_tsquery(search_string).alias('query') >>> >q = q.filter(cls.tsv.op('@@')(text_query)) >>> >if raw_search: >>> >q = q.order_by(Product.name.op('ilike')(raw_search + >>> > '%').desc()) >>> >q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, >>> > sa.literal_column('query'), 1))) >>> >return q >>> > >>> > AttributeError: Element to_tsquery(:to_tsquery_1) does not support >>> > 'as_scalar()' >>> >>> you probably don't want to call "alias('query')" on the func.to_tsquery() >>> object. that turns it into an aliased SELECT construct that isn't >>> particularly appropriate to pass to an operator ('@@' above). >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "sqlalchemy" group. >>> To post to this group, send email to sqlalchemy@googlegroups.com. >>> To unsubscribe from this group, send email to >>> sqlalchemy+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/sqlalchemy?hl=en. >>> >>> >> >> >> -- >> "How can anything be impossible when impossible itself says I M >> Possible???" >> Mihir >> > > > > -- > "How can anything be impossible when impossible itself says I M > Possible???" > Mihir > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For
Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
this has to do with how the Session is configured and if its linked to an engine. Curious, the "upgrade" happening here is strictly because a newer version of Debian has a different version of SQLAlchemy ?It would be really, really preferable if you could run the specific version of SQLAlchemy the app was written against, we change the API with each 0.x version.This does however mean you'd need to install SQLAlchemy using standard Python setuptools methodologies and not via a deb package.The effort you're making here would be towards porting the app to 0.5.8 based on your trace below...we're already up to 0.7. With a straight install, it only means SQLAlchemy would be installed under "site-packages" instead of "dist-packages". On Apr 29, 2011, at 8:54 PM, Mihir Sevak wrote: > Actually to be specific I am getting following error now > > > Errorlog > * > File '/home/mihir/development/web/web/controllers/real.py', line 187 in search > total_matches = matching_products.count() > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', > line 1552 in count > should_nest = should_nest[0] > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', > line 1583 in _col_aggregate > return self.session.scalar(s, params=self._params, > mapper=self._mapper_zero()) > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 758 in scalar > return self.execute(clause, params=params, mapper=mapper, **kw).scalar() > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 750 in execute > engine = self.get_bind(mapper, clause=clause, **kw) > File > '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', > line 888 in get_bind > ', '.join(context))) > UnboundExecutionError: Could not locate a bind configured on mapper > Mapper|Product|products, SQL expression or this Session > > *** > > On Fri, Apr 29, 2011 at 8:32 PM, Mihir Sevak wrote: > Hi Mike thanks very much for taking time to respond to my question. > > After taking the alias away it stopped complaining about that perticular > line. But the function which was calling this function did not get query > results. So tried to print "q" itself and it was the query-line itself instead > of results. > > Something like > > "SELECT xXXX DESC" > > Is there some change in the way to read the results from "q" object? > Because I have not changed a single letter of the code and what work > on other platform doesn't work here. So i am confused. > > > Thanks for your help. > > > On Fri, Apr 29, 2011 at 8:13 PM, Michael Bayer > wrote: > > On Apr 29, 2011, at 1:55 PM, Mihir wrote: > > > @classmethod > >def fulltext_adv(cls, search_string, raw_search=''): > >q = Session.query(cls) > >text_query = func.to_tsquery(search_string).alias('query') > >q = q.filter(cls.tsv.op('@@')(text_query)) > >if raw_search: > >q = q.order_by(Product.name.op('ilike')(raw_search + > > '%').desc()) > >q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, > > sa.literal_column('query'), 1))) > >return q > > > > AttributeError: Element to_tsquery(:to_tsquery_1) does not support > > 'as_scalar()' > > you probably don't want to call "alias('query')" on the func.to_tsquery() > object. that turns it into an aliased SELECT construct that isn't > particularly appropriate to pass to an operator ('@@' above). > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > > > > -- > "How can anything be impossible when impossible itself says I M Possible???" > Mihir > > > > -- > "How can anything be impossible when impossible itself says I M Possible???" > Mihir > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more op
Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
Actually to be specific I am getting following error now Errorlog * File '/home/mihir/development/web/web/controllers/real.py', line 187 in search total_matches = matching_products.count() File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', line 1552 in count should_nest = should_nest[0] File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/query.py', line 1583 in _col_aggregate return self.session.scalar(s, params=self._params, mapper=self._mapper_zero()) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', line 758 in scalar return self.execute(clause, params=params, mapper=mapper, **kw).scalar() File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', line 750 in execute engine = self.get_bind(mapper, clause=clause, **kw) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.8-py2.6.egg/sqlalchemy/orm/session.py', line 888 in get_bind ', '.join(context))) UnboundExecutionError: Could not locate a bind configured on mapper Mapper|Product|products, SQL expression or this Session *** On Fri, Apr 29, 2011 at 8:32 PM, Mihir Sevak wrote: > Hi Mike thanks very much for taking time to respond to my question. > > After taking the alias away it stopped complaining about that perticular > line. But the function which was calling this function did not get query > results. So tried to print "q" itself and it was the query-line itself > instead > of results. > > Something like > > "SELECT xXXX DESC" > > Is there some change in the way to read the results from "q" object? > Because I have not changed a single letter of the code and what work > on other platform doesn't work here. So i am confused. > > > Thanks for your help. > > > On Fri, Apr 29, 2011 at 8:13 PM, Michael Bayer > wrote: > >> >> On Apr 29, 2011, at 1:55 PM, Mihir wrote: >> >> > @classmethod >> >def fulltext_adv(cls, search_string, raw_search=''): >> >q = Session.query(cls) >> >text_query = func.to_tsquery(search_string).alias('query') >> >q = q.filter(cls.tsv.op('@@')(text_query)) >> >if raw_search: >> >q = q.order_by(Product.name.op('ilike')(raw_search + >> > '%').desc()) >> >q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, >> > sa.literal_column('query'), 1))) >> >return q >> > >> > AttributeError: Element to_tsquery(:to_tsquery_1) does not support >> > 'as_scalar()' >> >> you probably don't want to call "alias('query')" on the func.to_tsquery() >> object. that turns it into an aliased SELECT construct that isn't >> particularly appropriate to pass to an operator ('@@' above). >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to sqlalchemy@googlegroups.com. >> To unsubscribe from this group, send email to >> sqlalchemy+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/sqlalchemy?hl=en. >> >> > > > -- > "How can anything be impossible when impossible itself says I M > Possible???" > Mihir > -- "How can anything be impossible when impossible itself says I M Possible???" Mihir -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
Hi Mike thanks very much for taking time to respond to my question. After taking the alias away it stopped complaining about that perticular line. But the function which was calling this function did not get query results. So tried to print "q" itself and it was the query-line itself instead of results. Something like "SELECT xXXX DESC" Is there some change in the way to read the results from "q" object? Because I have not changed a single letter of the code and what work on other platform doesn't work here. So i am confused. Thanks for your help. On Fri, Apr 29, 2011 at 8:13 PM, Michael Bayer wrote: > > On Apr 29, 2011, at 1:55 PM, Mihir wrote: > > > @classmethod > >def fulltext_adv(cls, search_string, raw_search=''): > >q = Session.query(cls) > >text_query = func.to_tsquery(search_string).alias('query') > >q = q.filter(cls.tsv.op('@@')(text_query)) > >if raw_search: > >q = q.order_by(Product.name.op('ilike')(raw_search + > > '%').desc()) > >q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, > > sa.literal_column('query'), 1))) > >return q > > > > AttributeError: Element to_tsquery(:to_tsquery_1) does not support > > 'as_scalar()' > > you probably don't want to call "alias('query')" on the func.to_tsquery() > object. that turns it into an aliased SELECT construct that isn't > particularly appropriate to pass to an operator ('@@' above). > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- "How can anything be impossible when impossible itself says I M Possible???" Mihir -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Porting a project to sqlalchemy 0.6.x
On Apr 29, 2011, at 1:55 PM, Mihir wrote: > @classmethod >def fulltext_adv(cls, search_string, raw_search=''): >q = Session.query(cls) >text_query = func.to_tsquery(search_string).alias('query') >q = q.filter(cls.tsv.op('@@')(text_query)) >if raw_search: >q = q.order_by(Product.name.op('ilike')(raw_search + > '%').desc()) >q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, > sa.literal_column('query'), 1))) >return q > > AttributeError: Element to_tsquery(:to_tsquery_1) does not support > 'as_scalar()' you probably don't want to call "alias('query')" on the func.to_tsquery() object. that turns it into an aliased SELECT construct that isn't particularly appropriate to pass to an operator ('@@' above). -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Porting a project to sqlalchemy 0.6.x
Hello All, I am more of a C and C++ developer with basic knowledge of Databases. I am tasked with a project which is written in Python specifically in Pylons and uses Postgresql database engine. Following is a piece of code which was working with older version of Debian machine but now when upgraded machines it stopped working. I am listing the error log as well. Can you please give me some hints on what should be done to fix this problem? I really appreciate your help. Thanks in advance. Code @classmethod def fulltext_adv(cls, search_string, raw_search=''): q = Session.query(cls) text_query = func.to_tsquery(search_string).alias('query') q = q.filter(cls.tsv.op('@@')(text_query)) if raw_search: q = q.order_by(Product.name.op('ilike')(raw_search + '%').desc()) q = q.order_by(sa.desc(func.ts_rank_cd(cls.tsv, sa.literal_column('query'), 1))) return q = Errorlog ** File '/home/mihir/development/pylons/myweb/myweb/controllers/real.py', line 185 in search matching_products = Product.fulltext(search_string) File '/home/mihir/development/pylons/web/web/model/model.py', line 1094 in fulltext return cls.fulltext_adv(fixed_search, raw_search=search_string) File '/home/mihir/development/pylons/itrackrweb/itrackrweb/model/ model.py', line 1082 in fulltext_adv q = q.filter(cls.tsv.op('@@')(text_query)) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/expression.py', line 1535 in op return self.operate(operators.op, opstring, b) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/orm/attributes.py', line 127 in operate return op(self.comparator, *other, **kwargs) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/operators.py', line 42 in op return a.op(opstring)(b) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/expression.py', line 1535 in op return self.operate(operators.op, opstring, b) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/orm/properties.py', line 158 in operate return op(self.__clause_element__(), *other, **kwargs) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/operators.py', line 42 in op return a.op(opstring)(b) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/expression.py', line 1893 in return lambda other: self.__operate(operator, other) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/expression.py', line 1679 in __operate obj = self._check_literal(op, obj) File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/expression.py', line 1913 in _check_literal return other.as_scalar() File '/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6.7- py2.6.egg/sqlalchemy/sql/expression.py', line 3315 in as_scalar "'as_scalar()'" % self.element) AttributeError: Element to_tsquery(:to_tsquery_1) does not support 'as_scalar()' -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.