You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.5 KiB

# 导入需要的工具包
from py2neo import Graph, Node, Relationship, NodeMatcher, Subgraph
import pandas as pd
import numpy as np
import os
import sys
sys.path.append(os.getcwd())
from config import neo4j_url,neo4j_username,neo4j_password
from config import kg_data
# 连接Neo4j数据库
graph = Graph(neo4j_url, auth=(neo4j_username,neo4j_password) )
homework_id_cql = 'CREATE INDEX ON :作业(homework_id)'
print(graph.run(homework_id_cql))
homework_na_cql = 'CREATE INDEX ON :作业(homework_name)'
print(graph.run(homework_na_cql))
challenge_id_cql = 'CREATE INDEX ON :关卡(challenge_id)'
print(graph.run(challenge_id_cql))
challenge_name_cql = 'CREATE INDEX ON :关卡(challenge_name)'
print(graph.run(challenge_name_cql))
shixun_id_cql = 'CREATE INDEX ON :实训(shixun_id)'
print(graph.run(shixun_id_cql))
shixun_name_cql = 'CREATE INDEX ON :实训(shixun_name)'
print(graph.run(shixun_name_cql))
subject_id_cql = 'CREATE INDEX ON :实践课程(subject_id)'
print(graph.run(subject_id_cql))
subject_name_cql = 'CREATE INDEX ON :实践课程(subject_name)'
print(graph.run(subject_name_cql))
video_item_id_cql = 'CREATE INDEX ON :教学视频(video_item_id)'
print(graph.run(video_item_id_cql))
video_name_cql = 'CREATE INDEX ON :教学视频(video_name)'
print(graph.run(video_name_cql))
course_id_cql = 'CREATE INDEX ON :教学课堂(course_id)'
print(graph.run(course_id_cql))
course_name_cql = 'CREATE INDEX ON :教学课堂(course_name)'
print(graph.run(course_name_cql))
knowledge_id_cql = 'CREATE INDEX ON :知识点(knowledge_id)'
print(graph.run(knowledge_id_cql))
knowledge_cql = 'CREATE INDEX ON :知识点(knowledge)'
print(graph.run(knowledge_cql))
stage_id_cql = 'CREATE INDEX ON :章节(stage_id)'
print(graph.run(stage_id_cql))
stage_name_cql = 'CREATE INDEX ON :章节(stage_name)'
print(graph.run(stage_name_cql))
exercise_id_cql = 'CREATE INDEX ON :考试(exercise_id)'
print(graph.run(exercise_id_cql))
exercise_name_cql = 'CREATE INDEX ON :考试(exercise_name)'
print(graph.run(exercise_name_cql))
attachment_id_cql = 'CREATE INDEX ON :课件(attachment_id)'
print(graph.run(attachment_id_cql))
filename_cql = 'CREATE INDEX ON :课件(filename)'
print(graph.run(filename_cql))
set_att_link="""match(s:`实践课程`) match (s)-[:`课程章节`]->(st:`章节`) match (st)-[:`章节知识点`]->(k:`知识点`) match(k)-[:`知识点课件`]->(att:`课件`) set att.link="https://www.educoder.net/video/"+att.attachment_id+"?subject_id="+s.subject_id"""
print(graph.run(set_att_link))