little-brother / sqlite-gui

Lightweight SQLite editor for Windows
GNU General Public License v2.0
1.11k stars 52 forks source link

Open Pdf file with external editor (feature request) #98

Closed SilvioGrosso closed 2 years ago

SilvioGrosso commented 2 years ago

Hello @little-brother

Here is a feature request. Thanks a lot for considering it in case it might be added in the future sqlite-gui is indeed an amazing software :smile:

With Db Browser and other open source editors (e.g. Dbeaver) it is possible to open with an external editor some PDFs file stored as blob in a sqlite database. I would like to propose a simila option for sqlite-gui. More precisaly, for Windows and Linux.

To be more precise: create table images (id integer not null primary key, name text, image blob);

insert into images values (1, 'image1', readfile("D:\prova.pdf"))

Now I would like to open this PDF file with an external software: on Windows usually this is Acrobat reader.

Here is a screenshot with Db browser with this exact feature available (the PDF file is opened with Acrobat reader):

dbbrowser_pdf png

Here is a video where I show the steps to create a table with a PDF file (sqltie-gui) and how I open this pdf with dbeaver (Windows 10):

https://user-images.githubusercontent.com/33007383/154773011-b0e541b9-c2e9-446b-9113-e5c79f2b65f4.mp4

jungle-boogie commented 2 years ago

If pdf support is added, where would it end?

There’s also pictures, audio, video, etc that could be stored at a blob.

Does Browser 4 SQLite open all those files?

IMO, this may not be the best path forward for a lightweight gui app.

By the way, I assumed SQLite-gui works on windows only. Does it work on Linux as well?

SilvioGrosso commented 2 years ago

Hello @jungle-boogie

By the way, I assumed SQLite-gui works on windows only.

In all truth, I don't know. Most open source GUIs (dbeaver, db browser, sqlitestudio) for sqlite which I work with own a Linux version as well (on top of Windows...) :smile: Since most open source developers work on Linux I have assumed this is the case for little-brother as well :smile: Once in a while, I work on Linux (KDE desktop - Kubuntu) even though, at work, I usually run Windows 10

If pdf support is added, where would it end? There’s also pictures, audio, video, etc that could be stored at a blob.

This is very a technical question and it depends entirely on little-brother roadmap :smile:

In addition, in my experience, it is generally not suggested to store the whole blob in a database because with many files stored (images, pdf etc) it quickly slows down the performances. Usually, you only insert their path (pointing to a folder with these files).

My use-case is to store "small" files: 200-300 kb each. Usually my database might store 100 files at most (as blob). Total size of the final database would be around 20-30 Mb. In all truth, I have never stored any video (mp4 etc) or RAW (nef etc) images inside my databases and I suppose it is unlikely I would do so (for performances issues..) in the future.

Allowing to visualize PDFs as blob is implemented with many open source GUIs I work with (e.g. Dbeaver, Db browser). On Windows 10, they simply launch a different softwares (.exe). With many commercial softwares this feature is implemented as well. For instance take sqlmaestro: https://www.sqlmaestro.com/products/sqlite/maestro/help/06_05_00_blob_viewer/

With Db Browser, you can "only" launch an external application (e.g. Acrobat reader) to visualize your PDFs stored internally, in the database, as blobs. On the contrary, with images (png, jpeg) the support is good. For instance, with select queries you can, kind of, visualize a preview of your images in the query results. See this screenshot with a single image in the first row: immagine

little-brother commented 2 years ago
  1. Perhaps sqlite-gui can be run on Linux via Wine or similar software. I don't have Linux machine to check it. The app can't be run natively on Linux because it uses a platform depended code (Windows API) unlike SqliteStudio/DB4S. They use QT-library for cross-platform development. This library allows to have one code for Linux/Windows/etc, but it requires an addidional ~20mb disk size.
  2. open with an external editor some PDFs file stored as blob If pdf support is added, where would it end?

    Yes, it possible and it won't take a lot of code for any extensions. pdf, images and some other files have a standard file header. So the app should read first bytes of a blob, spot the appropriate extension, store the blob as <somename>.<ext> to a temporary folder and say to Windows to open this file. To show pdf, dwg (Autocad), psd (Photoshop), docx, xls or another files, that Windows doesn't support from a box, inside the application is required to use additional libraries that have signifigantly more size than sqlite-gui and a complicated development pipeline. That is why I avoid them.

little-brother commented 2 years ago

Done. Now you can open any BLOB-data in an external application.