Learn to Code ยท zero-dependency ยท MIT

larzquery

Query a list of dicts like a database.

Once you have a collection of records you need to ask questions of it. larzquery gives you a small chainable query language over a plain list of dicts - where, order_by, limit, select and aggregates - so you can express questions readably and see how database queries work underneath.

larzscript pkg install query
View on GitHub →Learn the stack

What you get

Try it

import "query" as query
let people = [{"name": "Ada", "age": 36}, {"name": "Bo", "age": 24}, {"name": "Cy", "age": 41}]
let q = query.limit(query.order_by(query.where(query.from_(people),
  fn(p) { return p["age"] > 20 }), "age", true), 2)
print(query.pluck(q, "name"))
print(query.avg(query.from_(people), "age"))
Output
[Cy, Ada]
33.6667

Why it's in the Larz Stack

larzquery is a real Larzscript package (larzscript pkg install query) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.