While the SQLite database itself supports embedded nulls without any problems, 
the command-line utility truncates values at the first null character, which 
can be very confusing if a field begins with a null character.

(I spent an hour debugging my code, trying to figure out why it was not writing 
the value to the field, only to realize eventually that my code was fine.  It 
was the debugging tool [that’s what I use the sqlite3 cli for] that was buggy.)

This excerpt from a terminal sessions demonstrates the problem.  You need to 
have the perl DBI and DBD::SQLite modules installed for it to work:

$ perl -MDBI -e 'my $dbh = 
DBI->connect("dbi:SQLite:dbname=/tmp/foo.sqlite","",""); $dbh->do("create table 
foo ( bar BLOB )"); $dbh->prepare("insert into foo values 
(?)")->execute("foo\0bar");'
$ sqlite3 /tmp/foo.sqlite 
SQLite version 3.18.0 2017-03-28 18:48:43
Enter ".help" for usage hints.
sqlite> select * from foo;
foo
sqlite> 

I don’t know how to get null characters into a database from the sqlite3 shell, 
if that is even possible.  If you do not have the perl modules installed, you 
can use:

$ perl -MCPAN -eshell

and then type ‘install DBI DBD::SQLite' at the cpan prompt.

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

Reply via email to