Addons/data/sqlite/Create

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

A sqlite database is an ordinary file. The sqlcreate function creates and opens a file, and returns a database locale.

sqlcreate

This creates a database, given a file name. Any existing file is overwritten.

For example:

   load 'data/sqlite'

   F=: '~temp/t1.db'
   db=: sqlcreate_psqlite_ F

   dir F
t1.db           0 20-Feb-17 17:59:55

   sqlcmd__db 'create table tab (name text, price int)'
0

   dir F
t1.db        8192 20-Feb-17 17:59:55

   sqltables__db''
┌───┐
│tab│
└───┘

   sqlinsert__db 'tab';('name';'price');<('anne';'bob');10 20
0

   sqlhead__db'tab'
┌────┬─────┐
│name│price│
├────┼─────┤
│anne│10   │
│bob │20   │
└────┴─────┘