# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
from com.ziclix.python.sql import zxJDBC

# open database
con = zxJDBC.connect('jdbc:sqlite:msgs.db', None, None, 'org.sqlite.JDBC')
# write message to database
c = con.cursor()
c.execute('INSERT INTO msgs (msg) VALUES (?)', ('Hi from Jython!', ))
con.commit()
# dump all messages in database
c = con.cursor()
c.execute('SELECT msg FROM msgs')
for row in c.fetchall():
    print('|' + row[0] + '|')
# close database
con.close()
