Ubuntu Linux の Python 3.2 で py2neo を使用して、SQLite3 データベースから neo4j にグラフを作成しています。速度はそれほど重要ではありませんが、グラフは合計 500 万行のうち、約 3 時間で 40,000 行 (SQL 行ごとに 1 つのリレーション) しか取得していません。
メインループは次のとおりです。
from py2neo import neo4j as neo
import sqlite3 as sql
#select all 5M rows from sql-database
sql_str = """select * from bigram_with_number"""
#loop through each row
for (freq, first, firstfreq, second, secondfreq) in sql_cursor.execute(sql_str):
# create the Cypher query string using cypher 2.0 with merge
# so that nodes are created only if needed
query = neo.CypherQuery(neo4j_db,"""
CYPHER 2.0
merge (n:word {form: {firstvar}, freq: {freqfirst}})
merge(m:word {form: {secondvar}, freq: {freqsecond}})
create unique (n)-[:bigram {freq: {freqbigram}}]->(m) return n, m""")
#execute the string with parameters from sql-query
result = query.execute(freqbigram = freq, firstvar = first, freqfirst=firstfreq, secondvar=second, freqsecond=secondfreq)
データベースは問題なく作成されますが、完了するまでに数週間かかります。これをより速く行うことは可能だと思います。