read/write binary data via tcl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

read/write binary data via tcl

rene
Hi all,

I try to read/write image files in tcl with sqlite.
I would like to keep it simple and not convert to/from base64.

1. write the image:

package req sqlite3
sqlite3 db test
db eval {create table img(data blob)}
set fd [open t.png r]
fconfigure $fd -translation binary
set c [read $fd]
close $fd
db eval {insert into img values(@c)}

2. read the image:

db eval {select * from img}

--> here I get back a string and not the original binary data?


Thank you
rene



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: read/write binary data via tcl

rene
Found a solution:) May be it could be included in the tcl interface
specification as well.

package req sqlite3
sqlite3 db :memory:
db eval {create tanle img(b blob)}
# save data
set fd [open test.png r]
fconfigure $fd -translation binary
set c1 [read $fd]
close $fd
db eval {insert into img values(@c1)}
set r [db last_insert_rowid]
# read data
set fd [db incrblob img b $r]
fconfigure $fd -translation binary
set c2 [read $fd]
close $fd




--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: read/write binary data via tcl

rene
Getting binary data back with incrblob is only possible with a writeable
database connection.
Is there a way to do this with a readonly database connection?


Thank you
rene



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: read/write binary data via tcl

rene
-readonly is it.

Sorry for the noise.



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users