Groups | Search | Server Info | Login | Register


Groups > comp.lang.tcl > #55612

Re: sqlite3 blob wrong

From Ralf Fassel <ralfixx@gmx.de>
Newsgroups comp.lang.tcl
Subject Re: sqlite3 blob wrong
Date 2026-03-23 09:53 +0100
Message-ID <ygabjgfvse9.fsf@akutech.de> (permalink)
References <1774012017-4652@newsgrouper.org> <10pjl58$1l1e1$1@dont-email.me> <1774250910-4652@newsgrouper.org>

Show all headers | View raw


* rene <user4652@newsgrouper.org.invalid>
| Rich <rich@example.invalid> posted:
>
| > As you didn't post a complete working code segment that messes the PNG 
| > up, we have nothing to go on to suggest which possible alternative may 
| > be the most probable.
| >
| Here is a working script. The problem is the same.
>
| ::sqlite3 ::d :memory:
| set f [::open t.png r]
| ::fconfigure $f -translation binary
| set c1 [::read $f]
| ::close $f
| ::d eval {create table t1(i integer, c BLOB);}
| ::d eval {insert into t1 values(1,$c1)}
| set c2 [::d eval {select c from t1 where i=1}]

I can confirm that the contents in the DB is altered after reading it
back:

    # read from t.png
    % foreach c [split [string range $c1 0 10] ""] { puts [format %02x [scan $c %c]] }
    89
    50
    4e
    47
    0d
    0a
    1a
    0a
    00
    00
    00

    # read back from sqlite
    % foreach c [split [string range $c2 0 10] ""] { puts [format %02x [scan $c %c]] }
    89
    50
    4e
    47
    5c
    72
    5c
    6e
    1a
    5c
    6e
    %

I.e. the binary \r\n (0x0d 0x0a) in c1 has been changed into
literal \ r \ n (0x5c 0x72 0x5c 0x6e) in c2.

I don't know nothing about blobs in sqlite, and whether the above method
is the correct way to handle binary content in the database, but if it
is, something somewhere in the line or processing translates the binary
content into the ASCII representation.

R'

Back to comp.lang.tcl | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

sqlite3 blob wrong rene <user4652@newsgrouper.org.invalid> - 2026-03-20 13:06 +0000
  Re: sqlite3 blob wrong Rich <rich@example.invalid> - 2026-03-20 14:21 +0000
    Re: sqlite3 blob wrong rene <user4652@newsgrouper.org.invalid> - 2026-03-23 07:28 +0000
      Re: sqlite3 blob wrong Ralf Fassel <ralfixx@gmx.de> - 2026-03-23 09:53 +0100
        Re: sqlite3 blob wrong rene <user4652@newsgrouper.org.invalid> - 2026-03-23 11:19 +0000
          Re: sqlite3 blob wrong Ralf Fassel <ralfixx@gmx.de> - 2026-03-23 16:06 +0100
            Re: sqlite3 blob wrong Rich <rich@example.invalid> - 2026-03-23 16:23 +0000
              Re: sqlite3 blob wrong Ralf Fassel <ralfixx@gmx.de> - 2026-03-23 19:32 +0100
      Re: sqlite3 blob wrong undroidwish <undroidwish@googlemail.com> - 2026-03-23 12:27 +0100
        Re: sqlite3 blob wrong rene <user4652@newsgrouper.org.invalid> - 2026-03-23 12:42 +0000

csiph-web