Generation¶
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¶
-
quepy.mql_generation.choose_start_node(e)¶ Choose a node of the Expression such that no property leading to a data has to be reversed (with !).
-
quepy.mql_generation.generate_mql(e)¶ 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.
-
quepy.mql_generation.safely_to_unicode(x)¶ 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.
-
quepy.mql_generation.to_bidirected_graph(e)¶ 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.adapt(x)¶
-
quepy.sparql_generation.escape(string)¶
-
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.adapt(x)¶
-
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)¶
-
quepy.dot_generation.expression_to_dot(e)¶