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 file.
  • graphs – Graphs to create.
close()[source]

Close the SQLite connection.

find[source]

Returns a Query object.

setup_sql(graphs)[source]

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.

Parameters:
  • db – An SQLite connection.
  • lock – A threading.RLock instance.
abort()[source]

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

commit()[source]

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.

defined[source]

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

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.
perform_ops(cursor)[source]

Performs the stored operations on the given cursor object.

Parameters:cursor – The SQLite.Cursor object.
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.
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.
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=())[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.

Parameters:
  • statement – The SQL statements to append.
  • params – The parameters to append.
difference[source]

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

intersection[source]

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

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.

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

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

Previous topic

Usage

This Page