Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from neo4jrestclient.client import GraphDatabase
- from neo4jrestclient import client
- import psycopg2
- import csv
- db = GraphDatabase("http://127.0.0.1:7474",username="neo4j", password="1234")
- conn = psycopg2.connect("\
- dbname='bdTrmmTest'\
- user='postgres'\
- host='127.0.0.1'\
- password='1234'\
- ");
- inicio = 0
- while(inicio <= 4429640):
- c = conn.cursor()
- c.execute("SELECT p.latitude, p.longitude, h.precipitacaoh FROM pontos AS p, historico AS h WHERE p.gid = h.gidgeo_fk LIMIT 1640 OFFSET %d"%(inicio))
- sensorlatlong = db.labels.create("LaLo")
- sensorprecip = db.labels.create("Precipitacao")
- records = c.fetchall() #pega todos os resultados do select e armazena em uma tupla
- #cria todos os sensores os latitude e longitute
- for i in records:
- s2 = db.nodes.create(precipitacao=i[2])
- sensorprecip.add(s2)
- q = 'MATCH (s:LaLo) WHERE s.latitude ='+i[0]+' AND s.longitude ='+i[1]+' RETURN s'
- results = db.query(q, returns=(client.Node))
- if (q ) #I DON'T KNOW WHAT TO DO HERE TO KNOW IF NODE EXISTS OR NOT
- inicio = inicio+1640
Add Comment
Please, Sign In to add comment