[Cubicweb] Using only Yams and RQL with SQLite

Sylvain Thénault sylvain.thenault at logilab.fr
Sat Feb 27 09:54:55 CET 2010


On 27 février 00:10, Yann Cointepas wrote:
> Sorry for my previous empty message. I still do not understand how I sent it
> (I should go to sleep).

no problem
 
> With Sylvain's advices, I have been able to load a schema and initialise a
> database but when I try to convert an RQL query to SQL I have an exception
> that is quite hard to track for me:
> 
> yann at petityann:~/cubicweb/embedded_cubicweb$ python embedded_cubicweb.py
> Schema: <yams.schema.Schema object at 0x87877ac>
> Traceback (most recent call last):
>   File "embedded_cubicweb.py", line 47, in <module>
>     print rql2sql( rql, {}, rql_helper, sql_generator )
>   File "embedded_cubicweb.py", line 20, in rql2sql
>     return sql_generator.generate( rqlst, args )
>   File "/usr/local/cubicweb/cubicweb/server/sources/rql2sql.py", line 369,
> in generate
>     sql = self.union_sql(union)
>   File "/usr/local/cubicweb/cubicweb/server/sources/rql2sql.py", line 389,
> in noparen_union_sql
>     return '\nUNION ALL\n'.join(sqls)
>   File "/usr/local/cubicweb/cubicweb/server/sources/rql2sql.py", line 388,
> in <genexpr>
>     for i, select in enumerate(union.children))
>   File "/usr/local/cubicweb/cubicweb/server/sources/rql2sql.py", line 401,
> in select_sql
>     distinct = selectsortterms = select.need_distinct
> *AttributeError: 'VariableRef' object has no attribute 'need_distinct'

sounds like the rql2sql generator got something else than an Union node
as input (eg the root node for *read* queries. That make me think about 
something I have not told you: the sql generator is currently only handling
*read* query, no write query.

In cubicweb, what we're doing for write query is extracting a read query
from it (in cw.server.ssplanner), fetching results, and then calling
data source api (see cw.server.sources.native) to insert/delete entities
and relation.

Being able to generate SQL write queries directly from rql would be 
interesting though, even if not directly usable in cubicweb. Huum,
actually now that I think about it I may work on that for a customer
next week :D

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org




More information about the Cubicweb mailing list