Working with BLOBs

The application being developed needs to be able to store BLOBs associated
with rows in some tables. These BLOBs are most commonly scanned PDF versions
of documents; sometimes they might be digital images. I have no experience
using BLOBs. They are handled by SQLAlchemy and both SQLite and PostgreSQL.

   My Web search found one hit that was not helpful in teaching me how to add
and retrieve/display BLOBs with wxPython. A pointer to an appropriate doc is
needed.

TIA,

Rich

Hi Rich,

  The application being developed needs to be able to store BLOBs associated
with rows in some tables. These BLOBs are most commonly scanned PDF versions
of documents; sometimes they might be digital images. I have no experience
using BLOBs. They are handled by SQLAlchemy and both SQLite and PostgreSQL.

  My Web search found one hit that was not helpful in teaching me how to add
and retrieve/display BLOBs with wxPython. A pointer to an appropriate doc is
needed.

Can't help with a doc pointer.

You might want to consider as an alternative to store the files in the file system and not within the database and then just hold a pointer/path to the file within the database. You would need a network share to make this work - which might not be an option:-( .

Just looking at the SA doc I noted the LargeBinary datatype, and I saw this google group message with M. Bayer's comment - Redirecting to Google Groups

Obviously haven't tried it but it looks like you could just do something along this:

yourModel.yourlargebinarycolumn = open(yourfile.pdf, 'rb')
yourModel.binarydatatype = 'pdf'
yourModel.filename = 'yourfile.pdf'

Werner

···

On 2/21/2015 22:55, Rich Shepard wrote:

Can't help with a doc pointer.

Werner,

   I'll keep looking, thanks.

You might want to consider as an alternative to store the files in the
file system and not within the database and then just hold a pointer/path
to the file within the database. You would need a network share to make
this work - which might not be an option:-( .

   This is one of the questions I need to answer. Both SQLite and postgres
can store large amounts of data which allows the applicaton to store all
relevant data in one file (sqlite) or database (postgres). There's no need
for NFS connections between network hosts and backups (assuming they're
done) include all data without extra effort.

   Most documents will be short, a few pages at most. However, I've seen an
air quality permit that's about 70 pages long so the files, particularly
when they're scanned, can be large.

Just looking at the SA doc I noted the LargeBinary datatype, and I saw this google group message with M. Bayer's comment - Redirecting to Google Groups

Obviously haven't tried it but it looks like you could just do something along this:

yourModel.yourlargebinarycolumn = open(yourfile.pdf, 'rb')
yourModel.binarydatatype = 'pdf'
yourModel.filename = 'yourfile.pdf'

   I saw the SA data type (haven't closely examined it yet). Still unclear
how I handle this with wxPython. For example, should there be a grid widget
on each notebook tab which might have associated documents? Should there be
a separate tab, 'Documents,' which is a grid and lists all stored docs by
a primary key and foreign key to the tab with which each is associated?

   If you were to store images of wine bottles, vineyards, and reviews in
your wine database, how would you do it?

Thanks,

Rich

···

On Sun, 22 Feb 2015, Werner wrote:

Hi Rich,

Can't help with a doc pointer.

Werner,

  I'll keep looking, thanks.

You might want to consider as an alternative to store the files in the
file system and not within the database and then just hold a pointer/path
to the file within the database. You would need a network share to make
this work - which might not be an option:-( .

  This is one of the questions I need to answer. Both SQLite and postgres
can store large amounts of data which allows the applicaton to store all
relevant data in one file (sqlite) or database (postgres). There's no need
for NFS connections between network hosts and backups (assuming they're
done) include all data without extra effort.

  Most documents will be short, a few pages at most. However, I've seen an
air quality permit that's about 70 pages long so the files, particularly
when they're scanned, can be large.

Just looking at the SA doc I noted the LargeBinary datatype, and I saw this google group message with M. Bayer's comment - Redirecting to Google Groups

Obviously haven't tried it but it looks like you could just do something along this:

yourModel.yourlargebinarycolumn = open(yourfile.pdf, 'rb')
yourModel.binarydatatype = 'pdf'
yourModel.filename = 'yourfile.pdf'

  I saw the SA data type (haven't closely examined it yet). Still unclear
how I handle this with wxPython. For example, should there be a grid widget
on each notebook tab which might have associated documents? Should there be
a separate tab, 'Documents,' which is a grid and lists all stored docs by
a primary key and foreign key to the tab with which each is associated?

  If you were to store images of wine bottles, vineyards, and reviews in
your wine database, how would you do it?

I have a tab "Images, PDF & Web links" which has an ObjectListView on the right listing all the entries in a table, each entry is either an image, a PDF doc or a web link. If you click on an image it is shown on the left and all the entries can be opened with the appropriate external viewer, using desktop ( desktop · PyPI) to find the appropriate viewer. On opening the tab the first image is automatically shown.

Werner

···

On 2/22/2015 15:48, Rich Shepard wrote:

On Sun, 22 Feb 2015, Werner wrote:

Thanks, Werner. I will read and learn how to implement this feature.

   Many new things for me in this application.

Regards,

Rich

···

On Mon, 23 Feb 2015, Werner wrote:

I have a tab "Images, PDF & Web links" which has an ObjectListView on the
right listing all the entries in a table, each entry is either an image, a
PDF doc or a web link. If you click on an image it is shown on the left
and all the entries can be opened with the appropriate external viewer,
using desktop ( desktop · PyPI) to find the
appropriate viewer. On opening the tab the first image is automatically
shown.