API Documentation¶
-
graphlite.
connect
(uri, graphs=())[source]¶ Returns a Graph object with the given uri and created graphs.
Parameters: - uri – The URI to the SQLite DB.
- graphs – The graphs to create.
-
class
graphlite.graph.
Graph
(uri, graphs=())[source]¶ Initializes a new Graph object.
Parameters: - uri – The URI of the SQLite db.
- graphs – Graphs to create.
-
find
¶ Returns a Query object that acts on the graph.
-
class
graphlite.transaction.
Transaction
(db, lock)[source]¶ Represents a single, atomic transaction. All calls are delayed jobs- they do not execute until the transaction is committed.
Parameters: - db – An SQLite connection.
- lock – A threading.Lock instance.
-
abort
()[source]¶ Raises an
AbortSignal
. If you used theGraph.transaction
context manager this exception is automatically caught and ignored.
-
commit
()[source]¶ Commits the stored changes to the database. You don’t have to call this function if the transaction object is used as a context manager. A transaction can only be committed once.
-
delete
(edge)[source]¶ Deletes an edge from the database. Either the source node or destination node may be specified, but the relation has to be specified.
Parameters: edge – The edge.
-
delete_many
(edges)[source]¶ Delete multiple edge queries from the database. Best used when you have a fairly large generator that shouldn’t be loaded into memory at once for efficiency reasons.
Parameters: edges – An iterable of edges or Graph.find
style edge queries to delete.
-
perform_ops
()[source]¶ Performs the stored operations on the database connection. Only to be called when within a lock and a database transaction by the
commit
method.
-
store
(edge)[source]¶ Store an edge in the database. Both the source and destination nodes must be specified, as well as the relation.
Parameters: edge – The edge.
-
store_many
(edges)[source]¶ Store many edges into the database. Similar to the
graphlite.transaction.Transaction.delete_many()
method.Parameters: edges – An iterable of edges to store.
-
class
graphlite.query.
Query
(db, sql=(), params=())[source]¶ -
count
()[source]¶ Counts the objects returned by the query. You will not be able to iterate through this query again (with deterministic results, anyway).
-
derived
(statement, params=(), replace=False)[source]¶ Returns a new query object set up correctly with the statement and params appended to the end of the new instance’s internal query and params, along with the current instance’s connection.
Parameters: - statement – The SQL query string to append.
- params – The parameters to append.
- replace – Whether to replace the entire SQL query.
-
difference
¶ Compute the difference between the current selected nodes and the another query, and not a symmetric difference. Similar in implementation to
graphlite.query.Query.intersection()
.
-
intersection
¶ Intersect the current query with another one using an SQL INTERSECT.
-
statement
¶ Joins all of the SQL queries together and then returns the result. It is the query to be ran.
-
to
(datatype)[source]¶ Converts this iterable into another datatype by calling the provided datatype with the instance as the sole argument.
Parameters: datatype – The datatype.
-
traverse
(edge)[source]¶ Traverse the graph, and selecting the destination nodes for a particular relation that the selected nodes are a source of, i.e. select the friends of my friends. You can traverse indefinitely.
Parameters: edge – The edge query. If the edge’s destination node is specified then the source nodes will be selected.
-
union
¶ Compute the union between the current selected nodes and another query. Similar to the
graphlite.query.Query.intersection()
method.
-