Page 1 of 41 [prev] [next] |
Overview Of SQLite |
Page 2 of 41 [prev] [next] |
|
|
Overview Of SQLite |
Page 3 of 41 [prev] [next] |
Overview Of SQLite |
Page 4 of 41 [prev] [next] |
Users Of SQLite |
Page 5 of 41 [prev] [next] |
|
|
|
History Of SQLite |
Page 6 of 41 [prev] [next] |
Why Tcl And SQLite Make A Good Team |
Page 7 of 41 [prev] [next] |
|
|
Page 8 of 41 [prev] [next] |
Using SQLite With Tcl - Getting Started |
Page 9 of 41 [prev] [next] |
load ./tclsqlite.so Sqlite3 sqlite3 db test.db db eval {CREATE TABLE t1(a,b,c)} db eval {INSERT INTO t1 VALUES(1,2,3)} db eval {INSERT INTO t1 VALUES('hello',NULL,'world')} db close
Using SQLite with Tcl - Querying |
Page 10 of 41 [prev] [next] |
sqlite3 db test.db puts [db eval {SELECT * FROM t1}]1 2 3 hello {} world
Using SQLite with Tcl - Querying |
Page 11 of 41 [prev] [next] |
db eval {SELECT * FROM t1} { puts a=$a puts b=$b puts c=$c }a=1 b=2 c=3 a=hello b= c=world
Using SQLite with Tcl - Querying |
Page 12 of 41 [prev] [next] |
db eval {SELECT a AS x, b AS y, c AS z FROM t1} { puts x=$x puts y=$y puts z=$z }x=1 y=2 z=3 x=hello y= z=world
Using SQLite with Tcl - Querying |
Page 13 of 41 [prev] [next] |
db eval {SELECT a AS x, b AS y, c AS z FROM t1} abc { parray abc }abc(*) = x y z abc(x) = 1 abc(y) = 2 abc(z) = 3 abc(*) = x y z abc(x) = hello abc(y) = abc(z) = world
Using SQLite with Tcl - Querying |
Page 14 of 41 [prev] [next] |
db eval {SELECT * FROM t1} { if {$a==1} break } puts a=$a puts b=$b puts c=$ca=1 b=2 c=3
Using SQLite with Tcl - Querying |
Page 15 of 41 [prev] [next] |
set a [db onecolumn {SELECT * FROM t1}] puts a=$aa=1
set a [db onecolumn {SELECT a FROM t1}] set a [lindex [db eval {SELECT a FROM t1 LIMIT 1}] 0] db eval {SELECT a FROM t1} break
Using SQLite with Tcl - Updates |
Page 16 of 41 [prev] [next] |
set fd [open bigfile.txt] set content [read $fd] close $fd set qcontent [string map {' ''} $content] db eval "INSERT INTO t1 VALUES(1,2,'$qcontent')"
Using SQLite with Tcl - Updates |
Page 17 of 41 [prev] [next] |
set fd [open bigfile.txt] set content [read $fd] close $fd db eval {INSERT INTO t1 VALUES(1,2,$content)}
Using SQLite with Tcl - User Defined Functions |
Page 18 of 41 [prev] [next] |
proc sql_sqrt {x} {return [expr {sqrt($x)}]} db function sqrt sql_sqrt
proc sql_eval {script} {return [uplevel #0 $script]} db function eval sql_eval db eval {SELECT eval(cmd) FROM cmdset}
Using SQLite with Tcl - Other Interface Features |
Page 19 of 41 [prev] [next] |
Page 20 of 41 [prev] [next] |
SQL Language Understood By SQLite |
Page 21 of 41 [prev] [next] |
Supported Features
|
Features Not Supported
|
SQLite Datatypes |
Page 22 of 41 [prev] [next] |
SQL Type Equivalent Tcl Type NULL Empty String 64-bit Signed Integer WideInt 64-bit IEEE Float Double Text String BLOB ByteArray
Datatypes (continued) |
Page 23 of 41 [prev] [next] |
If type declaration contains... Then the affinity is... "INT" Integer "CHAR" or "CLOB" or "TEXT" Text "BLOB" or there is no type declaration None Otherwise Numeric
ROWIDs |
Page 24 of 41 [prev] [next] |
SELECT rowid, * FROM table1;
CREATE TABLE table2(x); INSERT INTO table2(rowid, x) VALUES(123,'hi');
UPDATE table2 SET rowid=rowid-1 WHERE rowid=123;
Database Schema Information |
Page 25 of 41 [prev] [next] |
CREATE TABLE sqlite_master ( type text, name text, tbl_name text, rootpage integer, sql text );
Querying The Database Schema |
Page 26 of 41 [prev] [next] |
puts [db eval {SELECT name FROM sqlite_master WHERE type='table'}]t1
puts [db onecolumn {SELECT sql FROM sqlite_master WHERE name='t1'}]CREATE TABLE t1(a,b,c)
Working With Multiple Databases |
Page 27 of 41 [prev] [next] |
SELECT * FROM main.t1, ex1.t1
ATTACH DATABASE 'backup.db' AS backup; CREATE TABLE backup.table1 AS SELECT * FROM table1; DETACH DATABASE backup;
Conflict Resolution Algorithms |
Page 28 of 41 [prev] [next] |
CREATE TABLE tbl1( a INTEGER UNIQUE ON CONFLICT IGNORE, b ANY NOT NULL ON CONFLICT ROLLBACK );
CREATE UNIQUE INDEX idx1 ON tbl1(a,b) ON CONFLICT REPLACE;
Page 29 of 41 [prev] [next] |
SQLite In Traditional SQL Roles |
Page 30 of 41 [prev] [next] |
SQLite As Replacement For Ad Hoc Data Files |
Page 31 of 41 [prev] [next] |
SQLite As Internal Structured Data Format |
Page 32 of 41 [prev] [next] |
SQLite As Application File Format |
Page 33 of 41 [prev] [next] |
SQLite As Application File Format - First Approach |
Page 34 of 41 [prev] [next] |
SQLite As Application File Format - Second Approach |
Page 35 of 41 [prev] [next] |
SQLite As Application File Format - Third Approach |
Page 36 of 41 [prev] [next] |
SQLite As Application File Format - Undo/Redo |
Page 37 of 41 [prev] [next] |
SQLite Database As Program |
Page 38 of 41 [prev] [next] |
Page 39 of 41 [prev] [next] |
Summary And Conclusions |
Page 40 of 41 [prev] [next] |
Page 41 of 41 [prev] [next] |