精华
[分享] Neo4j 连接其他数据库
首先需要将对应JAR包 放入
/var/lib/neo4j/plugins 下(LINUX) ,WIN的话应该也是对应的 plugins 文件下
mysql
//jar 包 mysql-connector-java-8.0.11
CALL apoc.load.driver("com.mysql.jdbc.Driver");
WITH "jdbc:mysql://{host}/northwind?user={account}&password={password}&useUnicode=true&characterEncoding=utf8" as url
CALL apoc.load.jdbc(url,"select * from Company where id >$maxID limit 0,3000") YIELD row
RETURN count(*);
neo4j
call apoc.bolt.load(bolt地址,查询语句,查询语句参数)
call apoc.bolt.load("bolt://{account}:{password}@{host}",
"MATCH (n:Company) WHERE n.sub_company>1 with n skip $skip limit $limit return n as company",
{skip: 0,limit:10}) yield row
mongodb
//JAR 包 mongo-java-driver-3.4.2,mongodb-driver-3.4.2 ,mongodb-driver-core-3.4.2,bson-3.4.2 !重启后生效
//参数 含义 如下图
CALL apoc.mongodb.find('mongodb://{account}:{password}@{host}/?authSource={authDB}&ssh=true','{DBName}','{collection}',{name:'名称'},null,null,false,0,10) YIELD value
MATCH (com:Company{company:value.name})
return com.company,value.boss
通过接口的形式
WITH "https://api.caiyunapp.com/v2/TAkhjf8d1nlSlspN/119.76465,49.273644/realtime.jsonp" AS url
CALL apoc.load.json(url) YIELD value
RETURN value.result //json数据可以当map 直接读取