项目作者: goshaQ

项目描述 :
Tiny graph database
高级语言: Python
项目地址: git://github.com/goshaQ/lime.git
创建时间: 2018-04-09T15:52:14Z
项目社区:https://github.com/goshaQ/lime

开源协议:MIT License

下载


lime

Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Installing

  1. git clone https://github.com/goshaQ/lime
  2. cd lime/
  3. pip3 install -r requirements.txt

Additionally install libspatialindex

Running

  1. python3 cli.py

Running tests

  1. cd lime/tests/
  2. python3 run_tests.py

Built with

Work process

After running the cli.py two threads are created:

  • Reading the data from UDP:
    • ip=’127.0.0.1’
    • port=9001
  • Reading user queries

User queries

  • :help - if you want to read helper
  • :node - if you want to add a new node
  • :relationship - if you want to add a new relationship
  • :index - if you want to add an index
  • :remove - if you want to remove the node
  • :search - if you want to search in the Database
  • :quit - close the program

Attention

Whitespaces in queries are matter!

Insert nodes

There are two possible ways for adding data to the database:

  • Through UDP messages (mentioned before)
  • Using SimpleCypherQL queries

If you want to add the node, type this skeleton:

  1. CREATE (<nodeName>:<nodeLabel> {<properties>})
  2. RETURN <nodeName>

Example:

  1. CREATE (node:Figure {x: 10, y: 15, color: red})
  2. RETURN node

Add relationship

Skeleton of the query:

  1. MATCH (<nodeName>:<nodeLabel> {<properties>}), (<nodeName>:<nodeLabel> {properties})
  2. CREATE (a)-[r:<relationshipName> {properies}]->(b)
  3. RETURN <nodeName>, <nodeName>
  4. MATCH (<nodeName>:<nodeLabel> {<properties>}), (<nodeName>:<nodeLabel> {properties})
  5. CREATE (a)<-[r:<relationshipName> {properies}]-(b)
  6. RETURN <nodeName>, <nodeName>
  7. MATCH (<nodeName>:<nodeLabel> {<properties>}), (<nodeName>:<nodeLabel> {properties})
  8. CREATE (a)-[r:<relationshipName> {properies}]-(b)
  9. RETURN <nodeName>, <nodeName>

Example:

  1. MATCH (a:Figure {x: 10}), (b:Figure {x: 10, y:15})
  2. CREATE (a)-[r:LEFT {color: red}]->(b)
  3. RETURN a, b

Add index

Skeleton of the query:

  1. CREATE INDEX (<indexName>:<indexLabel> {<properties>})
  2. RETURN <indexName>

Example:

  1. CREATE INDEX (ind:Index {x: 10})
  2. RETURN ind

Node removing

Skeleton of the query:

  1. REMOVE (<nodeName>:<nodeLabel> {<properties>})
  2. RETURN <nodeName>

Example:

  1. REMOVE (node:Figure {x: 10, y:10})
  2. RETURN node

Search nodes

Get all nodes by label

Skeleton:

  1. MATCH (<nodeName>:<nodeLabel>)
  2. RETURN <nodeName>

Example:

  1. MATCH (node:Figure)
  2. RETURN node

Get node by properties

Skeleton:

  1. MATCH (<nodeName>:<nodeLabel> {<properties>})
  2. RETURN <nodeName>

Example:

  1. MATCH (node:Figure {x: 10, y: 16})
  2. RETURN node

Get nodes by relation

Skeleton:

  1. MATCH (<nodeName1>:<nodeLabel1> {<properties>})-[:<relation>]->(<nodeName2>:<nodeLabel2>)
  2. RETURN <nodeName2>
  3. MATCH (<nodeName1>:<nodeLabel1> {<properties>})-[:<relation> {<properties>}]->(<nodeName2>:<nodeLabel2>)
  4. RETURN <nodeName2>
  5. MATCH (<nodeName1>:<nodeLabel1> {<properties>})<-[:<relation> {<properties>}]-(<nodeName2>:<nodeLabel2>)
  6. RETURN <nodeName2>
  7. MATCH (<nodeName1>:<nodeLabel1> {<properties>})-[:<relation> {<properties>}]-(<nodeName2>:<nodeLabel2>)
  8. RETURN <nodeName2>

Example:

  1. MATCH (node1:Figure {x: 10, y: 19})-[:LEFT]->(node2:Figure)
  2. RETURN node2
  3. MATCH (node1:Figure {x: 10, y: 19})-[:LEFT {x: 14, color: red}]->(node2:Figure)
  4. RETURN node2
  5. MATCH (node1:Figure {x: 10, y: 19})<-[:LEFT {x: 14, color: red}]-(node2:Figure)
  6. RETURN node2
  7. MATCH (node1:Figure {x: 10, y: 19})-[:LEFT {x: 14, color: red}]-(node2:Figure)
  8. RETURN node2

Screenshots

Data access API:

alt text

alt text

alt text

Authors

License

This project is licensed under the MIT License.