Home

Awesome

Build status Codecov

<h1 align="center">SQLiteGraph</h1>

A Graph Database for Julia, built on top of SQLite.jl.

<br><br>

Definitions

SQLiteGraph.jl uses the Property Graph Model of the Cypher Query Language (PDF).

<br><br>

Edges and Nodes

struct Node
    id::Int
    labels::Vector{String}
    props::EasyConfig.Config
end

struct Edge
    source::Int
    target::Int
    type::String
    props::EasyConfig.Config
end
Node(id, labels...; props...)

Edge(source_id, target_id, type; props...)

<br><br>

Adding Elements to the Graph

using SQLiteGraph

db = DB()

insert!(db, Node(1, "Person", "Actor"; name="Tom Hanks"))

insert!(db, Node(2, "Movie"; title="Forest Gump"))

insert!(db, Edge(1, 2, "Acts In"; awards=["Best Actor in a Leading Role"]))

<br><br>

Editing Elements

insert! will not replace an existing node or edge. Instead, use replace!.

replace!(db, Node(2, "Movie"; title="Forest Gump", genre="Drama"))

<br><br>

Simple Queries

db[1]  # Node(1, "Person", "Actor"; name="Tom Hanks")

for node in db[:]
    println(node)
end

only(db["Movie"])  # Node(2, "Movie"; title="Forest Gump", genre="Drama")

# (Pretend the graph is populated with many more items.  The following return iterators.)

db[1, :, "Acts In"]  # All movies that Tom Hanks acts in

db[:, 2, "Acts In"]  # All actors in "Forest Gump"

db[1, 2, :]  # All relationships between "Tom Hanks" and "Forest Gump"

db[:, :, :]  # All edges

<br><br>

✨ Attribution ✨

SQLiteGraph is STRONGLY influenced by https://github.com/dpapathanasiou/simple-graph.

<br><br>

Under the Hood Details