On Tuesday, October 17, 2017 at 8:02:36 PM UTC-7, Jon Tara wrote: > > The documentation on blobs is frustratingly sparse! > > I am trying to extract some columns from a table in in SQLite database and > insert in same table in another SQLite database. > > I can't figure out how to copy of Blob attribute. > > Note that the column does not have Blob affinity (it has text affinity). > But the data in the attributes are blobs. > > I tried cast in the select: > > Sequel.cast(:sketchGradingPng,:blob).as(:sketchGradingPng), > > But doesn't solve the problem. Well, it might solve part of the problem: > > Without the cast I get: > > ArgumentError: invalid byte sequence in UTF-8 > > when reading the table. If I add the cast, that goes away. >
That's good. If the column has text affinity, the default would be to assume the values of the columns are text and not blob, and casting is the proper way to fix that. > (Note that :sketchGradingPng.cast(Blob) doesn't work. It says undefined > symbol Blob.) > Blob is not a ruby constant. You can use File instead of Blob and Sequel will translate it correctly. > > The problem seems to be in the insert. I get: > > SQLite3::SQLException: unrecognized token: "'�PNG > > I tried .to_sequel_blob on the attribute, but it says to_sequel_blob is > undefined. > > What do I have to do to copy a blob attribute from one table to another? > Try Sequel.blob(str), which should return a Sequel::SQL::Blob object. > And is there any comprehensive documentation on using Blobs in Sequel? > There is precious little that I can find. > Probably not., but I'll certainly consider pull requests. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
