J6/Addons/data/sqlite

From J Wiki
Jump to navigation Jump to search
User Guide | Installation | Development | Categories | Git | Build Log

data/sqlite - sqlite enhanced API for J

Provides J bindings to SQLite embedded engine. Contains direct library calls as well as array-based economical bulk API.
Based on sqlite 3.6.14.2, see http://www.sqlite.org/
Binaries for Windows and Linux; on Mac comes standard.
For examples, see test.ijs, bench.ijs in SVN. Includes sqlite browser, see browser.ijs, browser.reg.


Installation

Use JAL/Package Manager or download the sqlite archive from JAL:j601/addons and extract it into the ~addons/data/sqlite folder.

Usage

Load sqlite addon with the following line

   load 'data/sqlite'

Selecting

   17 colquery__db 'select * from P where WEIGHT=?;'
+---+-----+-----+------+-----+
|PID|PNAME|COLOR|WEIGHT|CITY |
+---+-----+-----+------+-----+
|P2 |Bolt |Green|17    |Paris|
|P3 |Screw|Blue |17    |Oslo |
+---+-----+-----+------+-----+

Error Handling

Errors are raised as J signal with error message.

   strquery__db 'select * from P1;'
|no such table: P1: sqlerr
|       sqlerr msg
   strquery__db 'select (* from P;'
|near "*": syntax error: sqlerr
|       sqlerr msg

SQLite Browser

SQLite Browser application views and queries database schema and data.

Sqlite br1.png

You can start SQLite Browser loading the data/sqlite/browser script: associating a key in J configuration, typing in session
   load 'data/sqlite/browser'

or from shell command line or shortcut
   j -jijx data/sqlite/browser

Usage

  • To connect to a database file, use File|Connect menu item.
  • To open or save SQL session script, use File|Open and File|Save menu items.

Auto Start

To associate .sqlite file extension on Windows, see browser.reg in the addon folder. Before running it, change the path to j.exe in the last line.

For other systems the Auto Start command line is:
   \home\user\j602\bin\jwd -jijx data/sqlite/browser $1

See Also

Authors