Help - Search - Member List - Calendar
Full Version: Microsoft Access storing images?
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Support our Sponsors!
Steve Gross
Is there a resource for using Perl to save and extract images from a
Microsoft Access database? I've looked in CPAN but I don't see anything.


______________________________________________________________
Steve Gross Tel:

Director of Information Technology Cell:
JESNA Fax:

www.jesna.org

Chris Devers
On Fri, 1 Jul 2005, Steve Gross wrote:

QUOTE
Is there a resource for using Perl to save and extract images from a
Microsoft Access database?  I've looked in CPAN but I don't see
anything.

I'm not a Windows programmer and haven't used Perl with Access, so this
won't be the answer you're looking for.

But, that said...

With MySQL and other databases, I've seen good arguments for *not*
storing binary data such as images directly in a database. In many
cases, it's much easier to store the images as regular files on your
filesystem, and use the database to store references to those files.

So, for example, if you were building a web site that had a company
phone book, you could have database fields for things like name, title,
phone number, email, office location, etc, along with the filesystem
path to a JPG image of that person. When the CGI script (or whatever)
is called to present this person's page, it looks up the filesystem path
as well, and converts that to a suitable <img src="..." /> tag.

Depending on your application, this may or may not make sense, but it's
worth considering, as it can make things much easier to manage.


And with *that* said, if you do feel it's necessary to keep the data
directly in Access, the same general techniques used for MySQL or any
other database should, in general, still apply, provided that you're
using the DBI database abstraction module. If you can't find anything
specific on getting binary data into Access with Perl, you may be able
to make use of instructions based on MySQL, PostgreSQL, Oracle, etc.



--
Chris Devers

Siegfried Heintze
I've done this in C++ with Access and it is supported. I suspect it is quite
possible with Perl. Since you cannot represent, for example, gif images as
character string literal (not easily, anyway) you read your gif image from a
file into a string and then bind it to a "?" in your SQL statement. Have you
tried that?

I looked at the Win32::ODBC interface in the book "Programming the Perl DBI"
and I did not see a way to bind -- which is surprising. But you can
certainly do it, and it is recommended, with the DBI interface. Try it and
let us know the results.

Siegfried

-----Original Message-----
From: Chris Devers [mailto:[Email Removed]]
Sent: Friday, July 01, 2005 1:52 PM
To: Steve Gross
Cc: Perl Beginners List
Subject: Re: Microsoft Access storing images?

On Fri, 1 Jul 2005, Steve Gross wrote:

QUOTE
Is there a resource for using Perl to save and extract images from a
Microsoft Access database?  I've looked in CPAN but I don't see
anything.

I'm not a Windows programmer and haven't used Perl with Access, so this
won't be the answer you're looking for.

But, that said...

With MySQL and other databases, I've seen good arguments for *not*
storing binary data such as images directly in a database. In many
cases, it's much easier to store the images as regular files on your
filesystem, and use the database to store references to those files.

So, for example, if you were building a web site that had a company
phone book, you could have database fields for things like name, title,
phone number, email, office location, etc, along with the filesystem
path to a JPG image of that person. When the CGI script (or whatever)
is called to present this person's page, it looks up the filesystem path
as well, and converts that to a suitable <img src="..." /> tag.

Depending on your application, this may or may not make sense, but it's
worth considering, as it can make things much easier to manage.


And with *that* said, if you do feel it's necessary to keep the data
directly in Access, the same general techniques used for MySQL or any
other database should, in general, still apply, provided that you're
using the DBI database abstraction module. If you can't find anything
specific on getting binary data into Access with Perl, you may be able
to make use of instructions based on MySQL, PostgreSQL, Oracle, etc.



--
Chris Devers

--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

David Van Ginneken
I used the following to extract executable files from a MS-SQL server.
Most likely will be able to do something similar with Access.

use strict;
use DBI;
my $dbh = DBI->connect("dbi:ODBC:SOMEDSN", 'someuser', 'somepassword')
or die "Error Connecting to DBn";
$dbh-> {'LongTruncOk'} = 1;
$dbh-> {'LongReadLen'} = 10000000;
my $sth = $dbh->prepare("Select filename, binary from sometable");
$sth->execute();
while (my ($filename, $binary) = $sth->fetchrow_array()) {
open (FILE, ">$filename.exe");
binmode FILE;
syswrite FILE, $binary;
close(FILE);
}


On 7/1/05, Steve Gross <[Email Removed]> wrote:
QUOTE
Is there a resource for using Perl to save and extract images from a
Microsoft Access database?  I've looked in CPAN but I don't see anything.


______________________________________________________________
Steve Gross                                                      Tel:

Director of Information Technology                    Cell:
JESNA                                                            Fax:

www.jesna.org






PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.