the world's most popular tcl extension · the world's most popular tcl extension d....

94
The World's Most Popular TCL Extension D. Richard Hipp 16 th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Upload: others

Post on 26-Jun-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

The World's MostPopular TCL Extension

D. Richard Hipp16th Annual Tcl/Tk Conference

Portland, OR2009-09-30

Page 2: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

“The only SQL database enginespecifically designed to workwith TCL”

Page 3: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 4: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 5: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SQLite is a TCL Extension

Page 6: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 7: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

DatabaseFiles on

Disk

SQL Database

Engine

Client

Client Client

Client

Page 8: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

DatabaseFiles on

Disk

SQL Database

Engine

Client

Client Client

Client

Page 9: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 10: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

DatabaseFiles on

Disk

Client

Client Client

Client

Page 11: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Application Tcl/Tk Code

High-levelSQL statements

Low-level diskreads & writes

Page 12: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

● Program at a higher level● Programming by specification● Heads-up programming

– Focus on your product, not on your underlying database

– Maintain “situational awareness”

Why SQL?

Page 13: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Do not underestimate the importance of situational awareness!

Page 14: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SELECT value FROM array WHERE name='userid';

Easier to do with an array or dict:

$array('userid')

Page 15: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SELECT eqptid, enclosureid FROM eqpt WHERE typeid IN ( SELECT typeid FROM typespec WHERE attrid=( SELECT attrid FROM attribute WHERE name='detect_autoactuate' ) AND value=1 INTERSECT SELECT typeid FROM typespec WHERE attrid=( SELECT attrid FROM attribute WHERE name='algorithm' ) AND value IN ('sensor','wetbulb') )

How many lines of TCL are required to do this using justarrays and dicts?

Page 16: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 17: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SELECT h.url, h.title, f.url, (SELECT b.parent FROM moz_bookmarks b JOIN moz_bookmarks t ON t.id = b.parent AND t.parent != ?1 WHERE b.type = 1 AND b.fk = h.id ORDER BY b.lastModified DESC LIMIT 1) AS parent, (SELECT b.title FROM moz_bookmarks b JOIN moz_bookmarks t ON t.id = b.parent AND t.parent != ?1 WHERE b.type = 1 AND b.fk = h.id ORDER BY b.lastModified DESC LIMIT 1) AS bookmark, (SELECT GROUP_CONCAT(t.title, ',') FROM moz_bookmarks b JOIN moz_bookmarks t ON t.id = b.parent AND t.parent = ?1 WHERE b.type = 1 AND b.fk = h.id) AS tags, h.visit_count, h.typed, h.frecency FROM moz_places_temp h LEFT OUTER JOIN moz_favicons f ON f.id = h.favicon_id WHERE h.frecency <> 0UNION ALL SELECT h.url, h.title, f.url, (SELECT b.parent FROM moz_bookmarks b JOIN moz_bookmarks t ON t.id = b.parent AND t.parent != ?1 WHERE b.type = 1 AND b.fk = h.id ORDER BY b.lastModified DESC LIMIT 1) AS parent, (SELECT b.title FROM moz_bookmarks b JOIN moz_bookmarks t ON t.id = b.parent AND t.parent != ?1 WHERE b.type = 1 AND b.fk = h.id ORDER BY b.lastModified DESC LIMIT 1) AS bookmark, (SELECT GROUP_CONCAT(t.title, ',') FROM moz_bookmarks b JOIN moz_bookmarks t ON t.id = b.parent AND t.parent = ?1 WHERE b.type = 1 AND b.fk = h.id) AS tags, h.visit_count, h.typed, h.frecency FROM moz_places h LEFT OUTER JOIN moz_favicons f ON f.id = h.favicon_id WHERE h.id NOT IN (SELECT id FROM moz_places_temp) AND h.frecency <> 0ORDER BY 9 DESC

Page 18: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Other benefits SQL & SQLite:

● Persistent● Transactional● Cross-platform● Widely known and understood● Faster● Fewer bugs● SQL is good at doing the very few things that

TCL does not already do well.

Page 19: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

tcl/tk

Page 20: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Aside: How do you classifySQLite in TCL?

● A “small language within a small language”?

● A meta-small language?

Page 21: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

% package require sqlite33.6.19% sqlite3 db database.db%

.Na me of the d a ta ba se fi le A n ew on e i s crea ted i f i t d oes

.n ot a l r ea d y exi st

Ne w o b je ct fo rc o n tr o ll i ng the d a ta b a se

Page 22: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { CREATE TABLE users( userid INTEGER, first_name VARCHAR(30), last_name VARCHAR(40) );}

“ ” Use the eva l m ethod to run SQL

Sem i colon sepa ra tes mu l t i ple .SQL sta temen ts

.Fi n a l sem i colon i s opti on a l

user first_name last_name

Page 23: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

user first_name last_name

db eval { CREATE TABLE users( userid INTEGER, first_name VARCHAR(30), last_name VARCHAR(40) );}

Page 24: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { CREATE TABLE users( userid INTEGER, first_name VARCHAR(30), last_name VARCHAR(40) );}

, Da ta types a re i gn ored mostly

user first_name last_name

Page 25: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Trad

ition

al S

QL ● Rigid typing

● Types declared on containers● Exceptions if type rules are violated

Page 26: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Trad

ition

al S

QL ● Rigid typing

● Types declared on containers● Exceptions if type rules are violated

● No types - everything is a string● Internal dual representation● Very flexible

Page 27: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Trad

ition

al S

QL ● Rigid typing

● Types declared on containers● Exceptions if type rules are violated

● No types - everything is a string● Internal dual representation● Very flexible

Page 28: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Trad

ition

al S

QL ● Rigid typing

● Types declared on containers● Exceptions if type rules are violated

● Type associated with values● Containers have a “suggested type”● All types accepted by every container

● No types - everything is a string● Internal dual representation● Very flexible

Page 29: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { CREATE TABLE users( userid INTEGER, first_name VARCHAR(30), last_name VARCHAR(40) );}

Va lu es con ver ted to i n teger . i f they ca n be Otherwi se

.stored a s they a re

user first_name last_name

Add i t i on a l i n form a ti on a t :// . . / 3 .http www sql i te org d a ta type htm l

.Va lu es con ver ted to str i n gs Len gth r estr i ct i on s a re i gn ored

Page 30: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { INSERT INTO users VALUES(1, 'D. Richard', 'Hipp')}

Use a n I NSERT sta tem en t to a d d da ta

Page 31: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

user first_name last_name

1 D. Richard Hipp

db eval { INSERT INTO users VALUES(1, 'D. Richard', 'Hipp')}

Page 32: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { SELECT user, first_name, last_name FROM users}1 {D. Richard} Hipp

Use a SELECT sta tem en t to extr a ct d a ta fr om the d a ta ba se

Page 33: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { SELECT user, first_name, last_name FROM users}1 {D. Richard} Hipp

Da ta retu rn ed i n a TCL l i st

Page 34: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

user first_name last_name

1 D. Richard Hipp

db eval { INSERT INTO users VALUES(2, 'Ginger', 'Wyrick')}

2 Ginger Wyrick

Page 35: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval { SELECT * FROM users}1 {D. Richard} Hipp 2 Ginger Wyrick

Add i t i on a l r ows of d a ta ju st ma ke the r etu rn ed l i st lon ger

Page 36: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

sqlite3 db database.dbdb eval {SELECT * FROM user} { puts userid=$userid puts “name=$first_name $last_name”}userid=1name=D. Richard Hippuserid=2name=Ginger Wyrick

Scr i pt r un s on ce for ea ch row i n resu l t

set

Column con ten ts store i n TCL va r i a bles

Page 37: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

sqlite3 db database.dbdb eval {SELECT * FROM user} { puts userid=$userid puts “name=$first_name $last_name” break}userid=1name=D. Richard Hipp “ ” “ ” brea k a n d con ti n u e work

i n the u sua l wa y

Page 38: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db eval {SELECT * FROM user} breakset userid1set first_nameD. Richardset last_nameHipp

Va r i a bles persi st a fter the la st i ter a t i on of the

loop

Page 39: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

user first_name last_name

1 D. Richard Hipp

picture

Ne w Co l u m n Ad d ed

db eval { ALTER TABLE user ADD COLUMN picture;}

Page 40: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

set in [open drh.jpg]fconfigure $in -translation binaryset drhphoto [read $in]close $indb eval { UPDATE user SET picture=$drhphoto WHERE user=1}

- ,Note the use of cu r ly br a cesn ot -double quotes

Page 41: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

set in [open drh.jpg]fconfigure $in -translation binaryset drhphoto [read $in]close $indb eval { UPDATE user SET picture=$drhphoto WHERE user=1}

No un n ecessa ry copyi n g or quoti n g of la rge

.objects

I mmun e to SQL i n ject i on a tta cks

Page 42: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

set in [open drh.jpg]fconfigure $in -translation binaryset drhphoto [read $in]close $indb eval { UPDATE user SET picture=@drhphoto WHERE user=1}

$ @ in stea d of to force the use of the ByteAr ra y

represen ta t i on

Page 43: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

db transaction { db eval {...} # other TCL code... db eval {...}}

Sta r t a tr a n sa cti on

COMMI T on success ROLLBACK on a n y er ror

Page 44: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

proc sqrtfunc {x} { return [expr {sqrt($x)}]}db function sqrt sqrtfuncdb eval { SELECT sqrt(id) FROM user}1.0 1.41421356237

Defi n e a n ew TCL fun ct i on

Regi ster the fun ct i on wi th SQLi te

Use the TCL fun cti on i n a n SQLi te query

Page 45: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

proc sqlitecon::_edit {original_text} { # Code here to implement a GUI editor # for $original_text and return the result.}db function edit ::sqlite::_edit

“ ” Crea te a n ew SQL fun cti on n a med ed i t “:: : : ”im plemen ted by the TCL proc sql i te _ed i t

Page 46: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 47: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Get Th i s

Go Here

Page 48: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

% package require Tk% source sqlitecon.txt% sqlitecon::create .console {sqlite> } test.db db%

Page 49: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 50: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 51: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 52: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Are you still not convincedthat SQLite is a TCL extension?

Page 53: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SQLite Written Mostly In TCL

Page 54: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

TCL must be installed on the developmentsystem in order to build SQLite.

TCL is required to test SQLite

All SQLite documentation is generated by TCL scripts.

Page 55: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

select-core { stack {line SELECT {or nil DISTINCT ALL} {loop result-column ,}} {optx FROM join-source} {optx WHERE expr} {optx GROUP BY {loop ordering-term ,} {optx HAVING expr}} }

See h tt p : //w i k i . tc l . tk /21 7 0 8 fo r a d d iti o n a l i n fo rm a ti on

Page 56: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

“SQLite would not exist without TCL”

Page 57: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SQLite is “different”

Page 58: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

is

“zero administration”

Page 59: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Database Administrators

Page 60: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 61: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 62: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

is to is toas

Page 63: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

● SQLite does not compete with Oracle

Page 64: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

● SQLite does not compete with Oracle● SQLite competes with fopen()

Page 65: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Portable File Format

● A database is a single ordinary disk file● No special naming conventions or required file

suffixes● Cross-platform: big/little-endian and 32/64-bit● Backwards compatible through 3.0.0● Promise to keep it compatible moving forward● Not tied to any particular programming

language.

Page 66: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 67: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

ApplicationFile Format

makes a great

Zero-Administration &Portable File Format

means

Page 68: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

c,s,v

10011010010111

homegrown

<xml/>

Page 69: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 70: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

SQLite as file format freebies

● No parsing and generating code to write● Atomic updates● Fast, built-in searching● Access via third-party tools● Simplified upgrade migration● Cross-platform file format● High-level query language

Page 71: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Small Footprint

gcc -Os -DSQLITE_THREADSAFE=0

gcc -O3 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1

293 KiB

845 KiB

Sizes Include TCL language bindingsValues current as of 2009-09-25

Page 72: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Single Source Code File

● The “amalgamation” source code file: sqlite3.c or tclsqlite3.c

● About 68,000 lines of ANSI C code● 3.9 MB● Few dependencies: libc and libtcl● Very simple to add to a larger C program● Very simple to build as a tclsh loadable library

Page 73: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30
Page 74: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

The “generic” folder in theTEA distribution of SQLitecontains exactly one file:

tclsqlite3.c

Page 75: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

bash> gcc -shared tclsqlite3.c -o tclsqlite3.sobash> tclsh% load ./tclsqlite3.so% sqlite3 db :memory:% db eval {SELECT sqlite_version()}3.6.19

Building a tclsh loadable library

Note Add -DSQLITE_THREADSAFE=0 for non-threadsafe tclsh

Page 76: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Other Features Of SQLite

● Gigibyte size BLOBs and strings

● Tebibyte size databases

● 100% branch test coverage

● Nested transactions

● Full text search● R-Trees● ATTACH DATABASE● Robust against power

loss, malloc() failures, and I/O errors.

● Referential integrity

Page 77: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Many companies andorganizations use SQLite...

Page 78: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Adobe Photoshop Lightroom

Page 79: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Adobe Reader

Page 80: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Mozilla Firefox

Page 81: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Symbian/Nokia

Page 82: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Google Android

Page 83: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

iPhone

Page 84: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

iPod & iTunes

Page 85: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

iStuff

Page 86: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Blackberry

Page 87: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Palm webOS

Page 88: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Skype

Page 89: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Sony Playstation

Page 90: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

... and so forth

Page 91: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Open Source

Page 92: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Have you looked at SQLite lately...

● Faster● CHECK constraints● SAVEPOINT and nested transactions● Enhanced query planner● 100% branch test coverage● Recursive triggers● FOREIGN KEY constraints● Sources managed using Fossil

Page 93: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

Closing Thoughts

? Shouldn't you be using SQLiteinstead of [open]?

? Why isn't tclsqlite3.c part of theTCL core?

? Can we get a TCL amalgamation?

Page 94: The World's Most Popular TCL Extension · The World's Most Popular TCL Extension D. Richard Hipp 16th Annual Tcl/Tk Conference Portland, OR 2009-09-30

tcl/tk