Hello!
There is simple example for "tempkey" extension (Public Domain license):
create table colors(name text);
insert into colors values ('Red');
insert into colors values ('Green');
insert into colors values ('Blue');
select tempkey_install(); -- temp table "tempkeys" wiil be created
select tempkey_increment('','',1) as counter, name from colors;
1|Red
2|Green
3|Blue
select tempkey_get('',''); -- current values for key name '' in key group name
''
3
--select tempkey_delete('',''); -- delete key name '' in key group name ''
select tempkey_uninstall(); -- delete all keys
The "key" extension is similar but is operate with non-temp table "keys".
Test script for module "key":
select 'ERROR' where key_install() is not null; --Create "keys" table.
select 'ERROR' where key_exists('common','nds%')!=0; --Check is param exists
select 'ERROR' where key_get('common','nds%') is not null; --Get _non-existing_
value _without_ default_value
select 'ERROR' where key_get('common','nds%',18)!='18'; --Get _non-existing_
value _with_ default_value
select 'ERROR' where key_set('common','nds%',10)!='10'; --Set value
select 'ERROR' where key_get('common','nds%')!='10'; --Get _existing_ value
select 'ERROR' where key_add('common','nds%',18) is not null; --Add _existing_
key
select 'ERROR' where key_replace('common','nds%',20)!='20'; --Replace
_existing_ key
select 'ERROR' where key_delete('common','nds%')!=1; --Delete existing key
select 'ERROR' where key_delete('common','nds%') is not null; --Delete
non-existing key
select 'ERROR' where key_delete('common') is not null; --Delete all keys in unit
select 'ERROR' where key_replace('common','nds%',20) is not null; --Replace
_non-existing_ key
select 'ERROR' where key_add('common','nds%',18)!='18'; --Add _non-existing_ key
select 'ERROR' where key_increment('common','num',10)!='10'; --Increment
_non-existing_ value
select 'ERROR' where key_increment('common','num',10)!='20'; --Increment
_existing_ value
select 'ERROR' where key_prepend('common','string','prepend-')!='prepend-';
--Prepend value
select 'ERROR' where
key_append('common','string','-append')!='prepend--append'; --Append value
select 'ERROR' where key_flush('common','string')!=1; --Flush existing key
select 'ERROR' where key_delete('common','string') is not null; --Flush
non-existing key
select 'ERROR' where key_uninstall() is not null; -- Drop all keys from "keys"
table.
SQLite build with some extra modules you can get from my debian repository:
deb http://mobigroup.ru/debian/ lenny main contrib non-free
deb-src http://mobigroup.ru/debian/ lenny main contrib non-free
Install repository keyring as
sudo aptitude install debian-mobigroup-keyring
Also you can get sources directly from
http://mobigroup.ru/debian/pool/main/s/sqlite3/
The patch file for current SQLite release is
http://mobigroup.ru/debian/pool/main/s/sqlite3/sqlite3_3.6.16-2.diff.gz
Best regards, Alexey Pechnikov.
http://pechnikov.tel/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users