Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you say “open as a PDF”, I assume that you mean that you want some external program to see the data as a file? The only ways to do that are either:</p> <ol> <li>Do some clever shenanigans with user-mode filesystems on Linux (or the equivalent on your OS) so that the database can be actually mounted, or</li> <li>Copy the data from the database into a temporary file with the right name (hint: keep that as a separate column in that table).</li> </ol> <p>There's also presenting it all as a webserver, but that's really the second with a browser in the mix; the data is still copied.</p> <p>On the other hand, if all you want to do is have the data as a stream that you can read or write from Tcl, the sqlite3 package has what you need:</p> <pre><i>dbcmd</i> <b>incrblob</b> ?<b>-readonly</b>? ?<i>db</i>? <i>table column rowid</i></pre> <p>Which returns a standard channel handle (though not one backed up by an OS handle, so be careful if using as a redirection with <code>exec</code>).</p> <hr> <p>[EDIT]: Here's how to getthe data out (replace <code>...</code> with a clause to get the right row, of course):</p> <pre><code># Open the DB sqlite3 db Docs.db # Open the file to write to set fileID [open $fileText w] fconfigure $fileID -translation binary # Write the BLOB db eval {SELECT Doc FROM Document WHERE ... LIMIT 1} row { puts -nonewline $fileID $row(Doc) } # We're done! close $fileID db close </code></pre> <p>Don't worry about the size of the BLOB; the Tcl <code>sqlite3</code> package passes it around efficiently. If you're still concerned, here's the other way (again, you'll need to replace <code>...</code> appropriately):</p> <pre><code># Open the DB sqlite3 db Docs.db # Open the file to write to set fileOut [open $fileText w] fconfigure $fileOut -translation binary # Get the BLOB as a (read-only) channel set fdBlob [db incrblob -readonly Document Doc ...] fconfigure $fdBlob -translation binary # Do the copy fcopy $fileOut $fdBlob # We're done! close $fdBlob close $fileOut db close </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload