Code generation from an expression to a database language.

The currently supported languages are:
  • MQL
  • Sparql
  • Dot: generation of graph images mainly for debugging.
quepy.generation.get_code(expression, language)

Given an expression and a supported language, it returns the query for that expression on that language.

MQL Generation


Choose a node of the Expression such that no property leading to a data has to be reversed (with !).


Generates a MQL query for the Expression e.

quepy.mql_generation.paths_from_root(graph, start)

Generates paths from start to every other node in graph and puts it in the returned dictionary paths. ie.: paths_from_node(graph, start)[node] is a list of the edge names used to get to node form start.

quepy.mql_generation.post_order_depth_first(graph, start)

Iterate over the nodes of the graph (is a tree) in a way such that every node is preceded by it’s childs. graph is a dict that represents the Expression graph. It’s a tree too beacuse Expressions are trees. start is the node to use as the root of the tree.


Given an “edge” (a relation) or “a data” from an Expression graph transform it into a unicode string fitted for insertion into a MQL query.


Rewrite the graph such that there are reversed edges for every forward edge. If an edge goes into a data, it should not be reversed.

Sparql Generation

Sparql generation code.

quepy.sparql_generation.expression_to_sparql(e, full=False)
quepy.sparql_generation.triple(a, p, b, indentation=0)

Dot Generation

Dot generation code.

quepy.dot_generation.dot_arc(a, label, b)
quepy.dot_generation.dot_attribute(a, key)
quepy.dot_generation.dot_fixed_type(a, fixedtype)
quepy.dot_generation.dot_keyword(a, key)
quepy.dot_generation.dot_type(a, t)
quepy.dot_generation.escape(x, add_quotes=True)