Package: ein-graph
Note:I do not make any claims to theCowboy Bebopassets, names, or trademarks.Graph-EinA graph database implemented inSQLite. This is
great for creating a standalone, single file graph database.InstallationTo install the project, run the following:pip install ein-graphUsageThe project generates a database file if one is not provided. The database itself
is accessible; however, theGraphobject is the typical interface that should
be used for interacting with the data stored.DatabaseSQLite database files are created for each separate database path that is provided.
These are utilized upon instantiation of theGraphobject, which will discover
each of the data objects stored in the file.The database can be connected to viaDBeaveror some other
database client if you'd like to explore the data.Note:For users that want to utilize additional SQLite features there are
methods for executing arbitrary statements/multiple statements.SchemasDatabases have a concept of "schemas" that are used to organize disparate nodes
and edges from each other. As such, a schema is needed for each of the node/edge
data points added.Schemas are stored in table-form as follows:<schema_name>_nodes
<schema_name>_edgesTo look at these in action use the following on your database using a database client:-- from "select-schemas.sql"SELECTnameFROMsqlite_masterWHEREtype='table'ANDtbl_nameLIKE'%'||?||'%';Note:The above should only be used after a setup has been performed to create
a client and add a schema.GraphTheGraphinstantiates with all current data in the supplied path.Graphs operate with "schemas" that help to logically separate different sub-graphs.
These graphs can be connected viaEdgeobjects to bridge clusters of nodes.Any data added/updated/deleted via theGraphis also reflected at the database
level at time of execution.fromein.graphimportGraphgraph=Graph(db_path="test.db")graph.add_schema("some_schema")NodesEachNodeobject is a representation of data stored in the database, all data
should be capable of being rendered to JSON.fromein.nodeimportNodenode=Node(schema_name="some_schema",id="my-id",body={"some-key":1,"other-key":"data"},)EdgesThe graph'sEdges are a pair of nodes with a relationship. These contain thesourceandtargetnodes (and optionallypropertiesfor weights).fromein.edgeimportEdgeedge=Edge(schema_name="some_schema",source=Node(...),target=Node(...),)To bridgeNodeobjects between two schemas theschema_name=argument
should be supplied. This will be the database schema that the edge is stored in,
but the schemas of thesourceandtargetwill be discovered from theNodeobjects.fromein.edgeimportEdgenode_one=Node(schema_name="some_schema",...,)node_two=Node(schema_name="some_other_schema",...,)edge=Edge(schema_name=node_one.schema_name,source=node_one,target=node_two,)print(edge.source_schema_name)# some_schemaprint(edge.target_schema_name)# some_other_schemaReleasing buildsTo release builds for the project we use a combination of tagging and changes tosetup.py.For any releases totest.pypi.orguse a change to theversion="..."inside ofsetup.py. Once a PR is merged into the main project the test release will be updated.Any prod releases topypi.orgrequire a tagged version number. This should be done locally
by running the following:gitcheckoutmaster
gitpullmaster
gittagv<version-number-here>
gitpushoriginv<version-number-here>Rollbacks of versionsTo roll a version back we need to delete the tagged release from the prod PyPI,
then delete the GitHub tag.git tag -d v<version-number-here>
git push origin :v<version-number-here>