Hello
I'm using sqlite3.51.0 under windows.
I read a png-file in binary mode and get:
set c1
?PNG
^Z...
After write and read with database:
$d eval {create table t1(i integer, c BLOB);}
$d eval {insert into t1(1,$c1)}
set c2 [$d eval {select c from t1 where i=1}]
I get the following:
set c2
PNG\r\n^Z\n
How could this happen?
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}]
* rene <[email protected]d>
| Could you please try to confirm with "@c1" instead of "$c1" in the insert statement?
| It was an advice from Richard Hipp, but it was not working on my side.
Same result, it does not make a difference whether I use $c1 or @c1 in
the sql.
If I store the database in a file (instead of memory) I can see the
correct binary PNG content in the disk file. So I guess it is the
readback which does the transformation.
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,114 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492510:16:17 |
| Calls: | 14,267 |
| Calls today: | 3 |
| Files: | 186,320 |
| D/L today: |
22,521 files (7,338M bytes) |
| Messages: | 2,518,347 |