# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
from dk.vajhoej.isam import Key0
from dk.vajhoej.isam.local import LocalIsamSource

import MsgRec

# open database
db = LocalIsamSource('msgs.isq', 'dk.vajhoej.vms.rms.IndexSequential', False)
# write message to database
db.create(MsgRec(8, 'Hi from Jython!'))
# dump all messages in database
it = db.readGE(MsgRec, Key0(0))
while it.read():
    msg = it.current()
    print('|' + msg.msg + '|')
# close database
db.close()
