API Documentation

graphlite.connect(uri, graphs=())[source]

Returns a Graph object with the given URI and created graphs.

  • uri – The URI to the SQLite DB.
  • graphs – The graphs to create.
class graphlite.graph.Graph(uri, graphs=[])[source]

Initializes a new Graph object.

  • uri – The URI of the SQLite file.
  • graphs – Graphs to create.

Close the SQLite connection.


Returns a Query object.


Sets up the SQL tables for the graph object, and creates indexes as well.

Parameters:graphs – The graphs to create.
transaction(*args, **kwds)[source]

A context manager that returns a Transaction object to the caller. All operations must then be performed on the transaction object.

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.

  • db – An SQLite connection.
  • lock – A threading.RLock instance.

Raises an AbortSignal. If you used the Graph.transaction context manager this exception is automatically caught and ignored.


Commits the stored changes to the database. Note that you do not have to call this function if you used the Graph.transaction context manager, or the transaction will be committed twice.


Returns true if there are any internal operations waiting to be performed when the commit method is called.


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.

Performs the stored operations on the given cursor object.

Parameters:cursor – The SQLite.Cursor object.

Store an edge in the database. Both the source and destination nodes must be specified, as well as the relation.

Parameters:edge – The edge.
class graphlite.query.Query(db, sql=(), params=())[source]

Create a new query object that acts on a particular SQLite connection instance.

Parameters:db – The SQLite connection.

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=())[source]

Returns a new query object set up correctly with the current query object’s statements and parameters appended to the start of the new one.

  • statement – The SQL statements to append.
  • params – The parameters to append.

Compute the difference between the current selected nodes and the another query, and explicitly not a symmetric difference. Similar to the :meth:Query.intersection


Intersect the current query with another one. The method doesn’t process the objects in a loop/set but uses an SQL query.


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.

Parameters:edge – The edge object. If the edge’s destination node is specified then the source nodes will be selected.

Compute the union between the current selected nodes and another query. Similar to the :meth:Query.intersection.

Previous topic


This Page