On Mar 28, 3:48 pm, Christian MICHON <[email protected]>
wrote:
> Hi,
>
> I tried to save such files, compressing them and storing them as
> blobs, but I could not get the original files back.
>
> So I tried with some 64b encoding, but I'm clearly losing disk space doing so.
>
> Is there a proper/efficient/supported way to add and retrieve a file
> as a binary blob in a sqlite db using Sequel? I did not manage to find
> much info around this, unfortunately.
>
> Thanks for any pointers you could share!
Adding a blob:
DB[:table].insert(:column=>File.read('filename').to_sequel_blob)
to_sequel_blob wraps the ruby String in a Sequel::SQL::Blob object,
and special literalization rules are applied (in some adapters).
For the adapters that support it, blobs will automatically be returned
wrapped in Sequel::SQL::Blob objects. Sequel::SQL::Blob is a subclass
of String, so reading them is fairly transparent to the user.
For best performance, you'll probably want to read about Sequel's
support for bound variables:
http://sequel.rubyforge.org/rdoc/files/doc/prepared_statements_rdoc.html
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.