slott56 / functional-SQL

An approach to writing function Python that parallels the concepts underlying the SQL select

Home Page:https://slott56.github.io/functional-SQL/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

functional-SQL

Python ruff-linter pyright-checker license sphinx

A library to help build SQL-like functionality without the overhead of a database.

See https://slott56.github.io/functional-SQL/_build/html/index.html for the documentation.

Some SQL

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

Some Python that does the same thing.

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. Yes it has lambda cr: cr. scattered around. The Python produces the same results as the SQL query, using essentially the same algorithm. You can write Python using the SQL algorithm design pattern. And without using a database.

About

An approach to writing function Python that parallels the concepts underlying the SQL select

https://slott56.github.io/functional-SQL/

License:Apache License 2.0


Languages

Language:Python 100.0%