Introduction

Contents

Introduction#

The Entity Query Language (EQL) is a relational query language that is pythonic, and intuitive.

The interface side of EQL is inspired by euROBIN entity query language white paper.

Basic Example#

An important feature of EQL is that you do not need to do operations like JOIN in SQL, this is performed implicitly. EQL tries to mirror your intent in a query statement with as little boilerplate code as possible. For example, attribute access with and equal check to another value is just as you expect:

from dataclasses import dataclass

from typing_extensions import List

from krrood.entity_query_language.entity import entity, an, let, contains, Symbol


@dataclass
class Body(Symbol):
    name: str


@dataclass
class World:
    id_: int
    bodies: List[Body]


world = World(1, [Body("Body1"), Body("Body2")])

body = let(Body, domain=world.bodies)
query = an(entity(body, contains(body.name, "2"),
                  body.name.startswith("Body"))
               )
print(*query.evaluate(), sep="\n")
Body(name='Body2')

where this creates a body variable that gets its values from world.bodies, and filters them to have their att “name” equal to “Body1”.

Note that it is possible to use both provided helper methods by EQL and other methods that are accessible through your object instance and use them as part of the query conditions.

It’s all your python definitions, and that is the beauty of it.