I've been working on an SQL interface, and right
now I'm at the point where basic SQLite support works. Here's an
example:
⍝ Load the
native library
'/home/emartenson/prog/apl-sqlite/lib_sqlite.so' ⎕FX
'SQL'
SQL
⍝ Open the
SQLite database in the file /tmp/foo
db ← SQL[1]
'/tmp/foo'
⍝ Run an SQL
statement to create a new table
db SQL[4]
'create table foo (id int primary key, value
varchar(10))'
⍝ Insert 10
rows of data into the table
{db
SQL[4] 'insert into foo (id,value) values (?,?)' ⍵
('foo:',⍕⍵)}¨ ⍳10
⍝ Select a few
rows of data from the table
8⎕CR db
SQL[3] 'select * from foo where id < 4'
┌→────────┐
↓1 ┌→────┐│
│ │foo:1││
│ └─────┘│
│2 ┌→────┐│
│ │foo:2││
│ └─────┘│
│3 ┌→────┐│
│ │foo:3││
│ └─────┘│
└∊────────┘
⍝ Close the
database
Contrary to the project name, it's written in a way so that
support for other SQL databases can be easily plugged in.
Regards,
Elias