Addons/data/sqlite/zFns

From J Wiki
Jump to navigation Jump to search
Overview | Basic Usage | Create | Definitions | zFns | Installation | Nulls | Examples | Quirks

Usually only one sqlite database is accessed at a time. In this case, it is convenient to use cover functions in the z locale that reference a global locDB with the sqlite instance.

To read in sqlite and the cover functions:

   load 'data/sqlite/sqlitez'

The cover functions are named with a db prefix as in dbreads for sqlreads__db. For example:

   dbopen '~addons/data/sqlite/db/sandp.db'

   dbtables''
┌─┬─┬──┐
│p│s│sp│
└─┴─┴──┘

   dbreads 'p where city="london" order by name'
┌───┬─────┬─────┬──────┬──────┐
│pid│name │color│weight│city  │
├───┼─────┼─────┼──────┼──────┤
│p6 │cog  │red  │19    │london│
│p1 │nut  │red  │12    │london│
│p4 │screw│red  │14    │london│
└───┴─────┴─────┴──────┴──────┘