2017-08-26 03:36:42 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from neo4j.v1 import GraphDatabase, basic_auth
|
|
|
|
|
|
|
|
# Initialize driver and create session.
|
2017-09-01 21:39:32 +08:00
|
|
|
port = sys.argv[2] if len(sys.argv) > 2 else '7687'
|
|
|
|
driver = GraphDatabase.driver('bolt://localhost:%s' % port,
|
2017-08-26 03:36:42 +08:00
|
|
|
auth=basic_auth('', ''),
|
|
|
|
encrypted=False)
|
|
|
|
session = driver.session()
|
|
|
|
|
|
|
|
# The fist program argument is path to a file with indexes.
|
|
|
|
try:
|
|
|
|
with open(sys.argv[1], "r") as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
session.run(line.strip()).consume()
|
|
|
|
print("%s -> DONE" % line.strip())
|
|
|
|
print("All indexes were created.")
|
|
|
|
except:
|
|
|
|
print("Frist argument is path to a file with indexes.")
|
|
|
|
|
|
|
|
# Do the cleanup.
|
|
|
|
session.close()
|
|
|
|
driver.close()
|