[sqlite] compressing BLOB

536 views
Skip to first unread message

Christoph P.U. Kukulies

unread,
Mar 2, 2012, 4:42:22 AM3/2/12
to General Discussion of SQLite Database
Since I'm inserting large files into the DB I'm wondering whether Sqlite
can do compression on the data BLOB by itself
or whether I should do that by programming when creating the BLOB?

--
Christoph Kukulies
_______________________________________________
sqlite-users mailing list
sqlite...@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Benoit Mortgat

unread,
Mar 2, 2012, 6:54:08 AM3/2/12
to General Discussion of SQLite Database
SQLite does not compress your blob and you will have to do that
programatically. However you can define your own with
sqlite_create_function_v2(): the prototype of your function would be

void compress(sqlite3_context *context, int argc, sqlite3_value **argv)
{
assert(argc==1);
void *data = sqlite3_value_blob(argv[0]);
int nBytes = sqlite3_value_bytes(argv[0]);

// allocate memory for result
.....
sqlite3_result_blob(...);
}

--
Benoit Mortgat
20, avenue Marcel Paul
69200 Vénissieux, France
+33 6 17 15 41 58
+33 4 27 11 61 23

Stephan Beal

unread,
Mar 2, 2012, 7:20:39 AM3/2/12
to General Discussion of SQLite Database
On Fri, Mar 2, 2012 at 12:54 PM, Benoit Mortgat <mor...@gmail.com> wrote:

> SQLite does not compress your blob and you will have to do that
> programatically. However you can define your own with
> sqlite_create_function_v2(): the prototype of your function would be
>

There's an implementation in the fossil source repo:

http://fossil-scm.org/index.html/artifact/41357470cd8b147dcea8c684ed131ebf29643650?ln=53-105

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

Reply all
Reply to author
Forward
0 new messages