I've published a framework for doing SQL-like programming in Pure Python -- no database required.

Here: https://github.com/slott56/functional-SQL. See the functional-SQL documentation.

This allows us to transform SQL:

SELECT n.name, v.c2
FROM names_table n, values_table v
WHERE n.code = v.c1

To pure Python:

Select(name=lambda cr: cr.n.name, value=lambda cr: cr.v.c2)
.from_(n=names_table, v=values_table)
.where(lambda cr: cr.n.code == cr.v.c1)

Yes, the Python is longer and cluttered with lambdas.

This produces the same results using a similar algorithm.

Most important, this works with table-like collections of Any class of Python objects.

This implements the essential SQL query algorithm:

  • having filter()
  • group-by reduce()
  • where filter()
  • select map()
  • from itertools.product()

This From-Select-Where-GroupBy-Having(Tables) design pattern is very handy. A lot of people think of processing data following this template. There's no reason, however, to inject the overhead of schema and database.