Skip to main content

A pure Python document and graph database engine

Project description


A pure Python document and graph database engine

The graph part is coming soon.


Strengths :

  • In one readable file
  • The Vertex class is subclassable

Weaknesses :

  • Due to its design, not fast as light


Creating a DocNetDB object

from docnetdb import DocNetDB, Vertex

# Use a string
database = DocNetDB("subfolder/file.ext")
# Or a Path
import pathlib
database = pathlib.Path(".") / "subfolder" / "file.ext"

Creating vertices

# Element assignment with item style
rush_hour = Vertex()
rush_hour["name"] = "Rush Hour"
rush_hour["length"] = 5.25
rush_hour["url"] = ""

# Element assignment with initial data dict
initial_data = dict(
    name="Nyakuza Manholes",
manholes = Vertex(initial_data)
# Or
manholes = Vertex.from_dict(initial_data)

Insert vertices in the database

rush_hour.is_inserted() # Returns False
database.insert(rush_hour) # Returns the place (1 in this case)
rush_hour.is_inserted() # Returns True # Returns 1

database.insert(manholes) # Returns the place (2 in this case)

# You can still add elements to a Vertex afterwards
rush_hour is database[1] # Returns True
manholes is database[2] # Returns True

Save the database to the file

Access vertices in the database

# Get the first vertex

# Get the vertices that have a length superior to 4 minutes
def custom_gate(vertex):
    return vertex["length"] > 4
gen = # Returns a generator

# It doesn't matter if a vertex doesn't have a "length" element, as the
# KeyError is automatically captured.

# Delete the filtered vertices (just "manholes" in this case)
for vertex in gen:

# "manholes" still exists, it was just detached from the database.
manholes["name"] # Returns "Nyakuza Manholes"
manholes.is_inserted() # Returns False

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for docnetdb, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size docnetdb-0.2-py3-none-any.whl (8.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size docnetdb-0.2.tar.gz (6.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page