Atom

SQLite database application

Save as notes.atom. Requires the optional SQLite build. It stores and lists notes in an in-memory database. For persistence pass a filename with -- notes.sqlite.

notes.atom
use os
use sqlite

func seed(connection):
    sqlite.exec(connection, 'create table if not exists notes (id integer primary key, text text)')
    return sqlite.exec(connection, 'insert into notes (text) values (?)', ['Pack test supplies'])

connection = sqlite.open(get(os.args, 0, ':memory:'))
try:
    sqlite.transaction(connection, seed)
    rows = sqlite.query(connection, 'select id, text from notes order by id')
    for note in rows:
        print('{note.id}. {note.text}')
finally:
    sqlite.close(connection)