Files
Novel-Map/backend/run_import.py
2026-03-31 17:18:30 +08:00

38 lines
765 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
独立命令行导入脚本。
用法:
python run_import.py # 增量导入MERGE不删除现有数据
python run_import.py --clear # 清空图谱后全量重新导入
"""
import sys
from dotenv import load_dotenv
from graph_query import get_driver
from graph_builder import build_graph
load_dotenv()
def main():
clear = "--clear" in sys.argv
print("Connecting to Neo4j...")
driver = get_driver()
driver.verify_connectivity()
print("Connected.\n")
build_graph(driver, clear=clear)
print("\nGraph stats:")
from graph_query import get_graph_stats
for k, v in get_graph_stats().items():
print(f" {k}: {v}")
driver.close()
if __name__ == "__main__":
main()