1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- ;; (library (database)
- ;; )
- (import
- (dbi dbi)
- (fslib))
- ;; Log into the database.
- (define db
- (dbi-open "sqlite3"
- (fsing-join "data" "lessons")))
- ;; Create a table.
- (dbi-query db "create table metadata (id INTEGER, description TEXT, source_note TEXT)")
- (dbi-query db "create table item
- (id INTEGER PRIMARY KEY,
- traditional TEXT,
- simplified TEXT,
- phonetic_script TEXT,
- native )")
- (dbi-query db "create table item_meta (id INTEGER, description TEXT, source_note TEXT)")
- ;; Look at the return status of the last SQL command
- (display db) (newline)
- ;; Populate the table with values.
- (dbi-query db "insert into hellotable ('id', 'name') values('33', 'ola')")
- (dbi-query db "insert into hellotable ('id', 'name') values('34', 'dzien dobre')")
- (dbi-query db "insert into hellotable ('id', 'name') values('44', 'annyong haseyo')")
- (display db) (newline)
- ;; Display each of the rows of the table, in turn.
- (dbi-query db "select * from hellotable")
- (display db) (newline)
- (write (dbi-get_row db)) (newline)
- (write (dbi-get_row db)) (newline)
- (write (dbi-get_row db)) (newline)
- (write (dbi-get_row db)) (newline)
- ;; Close the database.
- (dbi-close db)
- (display db) (newline)
|