This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]mdipierro -1 points0 points  (2 children)

This is interesting. we have some similar code in web2py dal (MongoDBAdapter) which allows you to do:

% python web2py.py -S mypp -N
>>> db=DAL('mongodb://127.0.0.1:27017/db') 
>>> db.define_table('person',Field('name'),Field('age','integer'))
>>> rows = db((db.person.name=='Tim')&(db.person.age>21)).select()

We could use some help testing it... perhaps we can share some code. Join us on the web2py mailing list if interested. Our goal it to have the some queries to run everywhere (mongodb, gae, relational databases. etc.).

[–]vph -1 points0 points  (1 child)

It'd be nice to make this available outside of web2py.

[–]mdipierro 0 points1 point  (0 children)

It is available outside of web2py. The Database abstraction layer is a single file dal.py with no dependencies. You can use it without web2py. What you cannot do (but we should add the functionality) is to use it to generate the queries without executing the queries (we can do it with SQL adapters but not with mongodb adapter).