build_graph: réorganisation du code en fonction
This commit is contained in:
parent
0d149bc9e7
commit
ea0be79129
|
@ -7,9 +7,6 @@ NEO4J_URI = "bolt://localhost:7687"
|
||||||
NEO4J_USR = "neo4j"
|
NEO4J_USR = "neo4j"
|
||||||
NEO4J_PSW = "test"
|
NEO4J_PSW = "test"
|
||||||
|
|
||||||
# Conection with Neo4j
|
|
||||||
driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USR, NEO4J_PSW))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def define_link_from_type(link_id):
|
def define_link_from_type(link_id):
|
||||||
|
@ -28,6 +25,10 @@ def define_link_from_type(link_id):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def create_graph():
|
||||||
|
"""
|
||||||
|
Build and insert graph from wikidata to neo4j
|
||||||
|
"""
|
||||||
# Create indexes
|
# Create indexes
|
||||||
with driver.session() as session:
|
with driver.session() as session:
|
||||||
session.run("CREATE INDEX ON :Disease(id);")
|
session.run("CREATE INDEX ON :Disease(id);")
|
||||||
|
@ -85,5 +86,12 @@ for link in request_disease_links:
|
||||||
signe_symptome_id=signe_symptome_id
|
signe_symptome_id=signe_symptome_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Conection with Neo4j
|
||||||
|
driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USR, NEO4J_PSW))
|
||||||
|
|
||||||
|
create_graph()
|
||||||
|
|
||||||
# Close Neo4j connection
|
# Close Neo4j connection
|
||||||
driver.close()
|
driver.close()
|
||||||
|
|
Loading…
Reference in New Issue