コード例 #1
0
def port_sv():
    print '---- Porting the SV database ----'
    db1 = connect_to_database()
    db1.add_son_manipulator(TransformToBinary())    
    db = NeoEngine('/data/neo4j')

    db.create_collection('sv')

    cnt = db1.sv.find().count()
    cntidx = bar([i for i in range(cnt)])
    for sv in db1.sv.find():
        #print type(sv['sv'].value())
        cntidx.next()
        data = {'speaker_name': _udecode(sv['speaker_name']),
                'sv': sv['sv'].value(),
                'random': random.random()}
        node = db.insert('sv', data)
        
        # check data integrity
        try:
            assert _udecode(sv['speaker_name']) == db.get('sv', {'id': node['id']})['speaker_name']
            assert np.array_equal(sv['sv'].value(), NeoCustomType(node['sv']))
        except Exception:
            print sv['speaker_name']
            db.shutdown()
        
    db.create_index('sv', 'speaker_name')

    db.shutdown()
コード例 #2
0
def port_speaker():
    print '---- Porting the Speaker database ----'
    db1 = connect_to_database()
    #db1.add_son_manipulator(TransformToBinary())

    # set up neo4j collection
    db = NeoEngine('/data/neo4j')

    db.create_collection('speaker')
    
    for speaker in bar(Speaker.objects):
        data = {'name': _udecode(speaker.name), 'gender': _udecode(speaker.gender),
                'language': _udecode(speaker.language),
                'dialect': _udecode(speaker.dialect)}
        node = db.insert('speaker', data)
    
    db.create_index('speaker', 'name')
    db.shutdown()