Hi Anand,
It's a nice change, however isn't this what the existing db.where() is for?
It's even simpler than what you have, and it gives the function a more
specific, meaningful name:
>>> db.where('post', category='popular', published=True, limit=5,
_test=True)
<sql: "SELECT * FROM post WHERE category = 'popular' AND published = 't'
LIMIT 5">
Re adding first() to IterBetter -- that's kinda nice, though wouldn't the
plain Python way of writing that either be "iter[0]" or "next(iter,
default)" if you want a default?
-Ben
On Tuesday, April 1, 2014 2:47:13 PM UTC-4, Anand wrote:
>
> Hi,
>
> I've made 2 improvement to the db module.
>
> 1. The where clauses can be a dict now.
>
> This makes it easier to write where clause without having to do $
> substitutions in the queries. It joins all the key-value pairs in the dict
> with AND.
>
> For example:
>
> >>> db.select("post", where={"category": "popular", "published": True},
> limit=5, _test=True)
> <sql: "SELECT * FROM post WHERE category = 'popular' AND published = 't'
> LIMIT 5">
>
> 2. Added first() method to IterBetter
>
> Now it is much easier to get the first row of query result.
>
> p = db.select("person", where={"email": "[email protected] <javascript:>
> "}).first()
>
> The code is checked in to the master branch as usual.
>
> https://github.com/webpy/webpy
>
> Please let me know your comments.
>
> Anand
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.