No announcement yet.

How to store a pdf file in a BLOB field of SQLITE ?

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to store a pdf file in a BLOB field of SQLITE ?

    I am having trouble figuring out how to successfully write a pdf file and/or image (jpg) to the SQLite database as a Blob, using PowerBASIC.

    How can I retrieve the pdf file and/or image (jpg) later from the BLOB field of the SQLite database ?

    I'm looking for sample PowerBASIC code.

    Thank you for your help.
    Last edited by Jean-Pierre LEROY; 14 Sep 2008, 07:37 AM.
    Jean-Pierre LEROY

  • #2
    You can bind to a blob field but the simpliest is to convert the PDF to hex.
    Then insert with X'your hex data here'
    The data will be stored as the original (1:1), not as hex.


    • #3
      I recently posted a SQLite image blob example in the source code forum, if that helps?
      Here is the link:
      Last edited by Chris Holbrook; 14 Sep 2008, 09:55 AM. Reason: added link


      • #4
        Edwin and Chris, thank you for your answers.

        Chris, I looked at your application. It is almost what I need; can I reuse parts of your code ? I just need to add a new option to re-create the jpg file directly after reading the image from the blob field (loadfromDB() function): not sure if I have to use the function readblob() or if can save the data right after the query when the image is in the buffer.
        Jean-Pierre LEROY


        • #5
          Originally posted by Jean-Pierre LEROY View Post
          can I reuse parts of your code ?
          certainly, at your own risk!

          ISTR that the application loads a blob from the DB then puts it into a temporary file from which GDI+ loads it, so the code you need may already be there.