User Contributed Notes 1 note

I wrote a script to transfer my old data from a mysql database, performing some changes to a sqlite3 database. When I realized that that the sqlite interfaces is no longer included in PHP and my PECL didn't get it installed it was too late.

However, there is a very easy, though not particularly performant way to get the job done like in the "sqlite_encode_blob" function I present below. Note that this does ONLY encode the data. To actually use it in a query you will have to wrap it like: X'data' See the example below.

The tricky part is to get the data back out of the database - that is not possible with the command line tool as far as I can tell. You will have to use a language with an actual API.

The following example is written in C and compiles on a linux box where the sqlite3 API is installed using:gcc -o test test.c `pkg-config --cflags --libs sqlite3`Note that this has absolutely no error checking whatsoever. If the slightest thing goes wrong it will likely cause a segmentation fault and likely leave the database corrupted.