Ignore the previous answer to your post; it's not right.

First, let's call things by their right names; '\' is a
backslash.

Second, the lines in your post that look sort of like the
transcript of a tcl session can't be real, or at least
can't be complete; so I'm going to have to make some
guesses.  I'm going to assume that the lines showing data
are the result of 'db eval "select ... "', and I'm going
to assume further that you did not specify a hash table
(tcl array) or code to execute with your select.  That
means that the result is a list (that's important).

When tcl prints a list, it escapes backslashes to prevent
them from escaping something else, like the white space
that separates the elements of the list.  Here's a real
transcript that may make it clearer:

%  set a [list "abc\\" "def"]
abc\\ def
% puts $a
abc\\ def
% lindex $a 0
abc\
% load tclsqlite.so
% sqlite db db
0x806fe58
% db eval "insert into test (data) values ('seven\\')"
% set aa [db eval "select data from test where pk = 7"]
seven\\
% set aa
seven\\
% lindex $aa 0
seven\
% db eval "insert into test (data) values ('\\eight\\')"
% set aa [db eval "select data from test where pk = 8"]
\\eight\\
% lindex $aa 0
\eight\

Tcl and SQLite are doing what you want them to; you're
just not handling the results of your queries correctly.
You might want to invest in a copy of Welch; don't make
the mistake of buying Ousterhout's book, which has been
obsolete for years.

Regards

Reply via email to