1. 简介
Neo4j is a highly scalable, robust native graph database.
Neo4j Sample Datasets
2. 启动测试
启动neo4j
docker run \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
neo4j
测试
hello neo4j地址:http://localhost:7474
账号:neo4j
密码:neo4j
点击Jump into code
,完成入门学习
3. Neo4j Desktop
一个Neo4j Instance,在同一时间只能激活一个Graph,不过,我们可以启动多个Instance。
通过Neo4j Desktop可以创建Local Instance,也可以管理多个Instance,包含Local和Remote。
-
Neo4j Desktop
Neo4j Desktop -
Neo4j Desktop Management for Local Instance
Neo4j Desktop Management for Local Instance -
Neo4j Browser
Neo4j Browser
4. Neo4j Client
- Neo4j Client (CLI and library)
https://neo4j-client.net/
https://github.com/cleishm/libneo4j-client
$ sudo add-apt-repository ppa:cleishm/neo4j
$ sudo apt-get update
$ sudo apt-get install neo4j-client libneo4j-client-dev
-
Neo4j Client
Neo4j Client -
Neo4j for C Language
#include <neo4j-client.h>
#include <errno.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
neo4j_client_init();
/* use NEO4J_INSECURE when connecting to disable TLS */
neo4j_connection_t *connection =
neo4j_connect("neo4j://user:pass@localhost:7687", NULL, NEO4J_INSECURE);
if (connection == NULL)
{
neo4j_perror(stderr, errno, "Connection failed");
return EXIT_FAILURE;
}
neo4j_result_stream_t *results =
neo4j_run(connection, "RETURN 'hello world'", neo4j_null);
if (results == NULL)
{
neo4j_perror(stderr, errno, "Failed to run statement");
return EXIT_FAILURE;
}
neo4j_result_t *result = neo4j_fetch_next(results);
if (result == NULL)
{
neo4j_perror(stderr, errno, "Failed to fetch result");
return EXIT_FAILURE;
}
neo4j_value_t value = neo4j_result_field(result, 0);
char buf[128];
printf("%s\n", neo4j_tostring(value, buf, sizeof(buf)));
neo4j_close_results(results);
neo4j_close(connection);
neo4j_client_cleanup();
return EXIT_SUCCESS;
}
5. Neo4j for Python
- install package
$ pip3.6 install neo4j
- hello.py
from neo4j.v1 import GraphDatabase
neo4j_uri = "bolt://localhost:7687"
auth_user = 'neo4j'
auth_psd = 'root'
class HelloWorldExample(object):
def __init__(self, uri, user, password):
self._driver = GraphDatabase.driver(uri, auth=(user, password))
def close(self):
self._driver.close()
def print_greeting(self, message):
with self._driver.session() as session:
greeting = session.write_transaction(self._create_and_return_greeting, message)
print(greeting)
# session.run()
@staticmethod
def _create_and_return_greeting(tx, message):
result = tx.run("CREATE (a:Greeting) "
"SET a.message = $message "
"RETURN a.message + ', from node ' + id(a)", message=message)
return result.single()[0]
if __name__ == '__main__':
print('run in main...')
example = HelloWorldExample(neo4j_uri, auth_user, auth_psd)
example.print_greeting('Hello Neo4j')
example.close()
- run hello.py
$ python3.6 hello.py
run in main...
Hello Neo4j, from node 179
6. Reference
-
neo4j desktop appimage for ubuntu
链接: https://pan.baidu.com/s/1XCSwTT4XEPWGNM8yF_tAcg
提取码: 9xnb -
neo4j official book
链接: https://pan.baidu.com/s/1oepXhDTQ_L95_wps-gTyCQ
提取码: tcu9 -
neo4j operations manual
https://neo4j.com/docs/operations-manual/current/introduction/ -
neo4j docker image
https://hub.docker.com/_/neo4j?tab=description
网友评论