473,382 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

working with blobs

Hi all,

Quick question... I am storing jpegs as blobs in a mysql table, which is
fine on my live server because I am just uploading them using phpmyadmin
(I am working with a small number of images that will rarely change and
thus do not have a need for an upload script). My problem is I do all
my testing on my local host where I do not have phpmyadmin, I do
everything with mysql through the command prompt. How can I insert rows
of binary data (jpegs) into my table through the command prompt? Thanks
very much in advance.

Marcus
Jul 23 '05 #1
6 1563
SOR
<comp.lang.php , Marcus , Ju********@aol.com>
<K5****************@newssvr31.news.prodigy.com>
<Sat, 23 Jul 2005 18:35:22 GMT>
Quick question... I am storing jpegs as blobs in a mysql table, which is
fine on my live server because I am just uploading them using phpmyadmin
(I am working with a small number of images that will rarely change and
thus do not have a need for an upload script). My problem is I do all
my testing on my local host where I do not have phpmyadmin, I do
everything with mysql through the command prompt. How can I insert rows
of binary data (jpegs) into my table through the command prompt? Thanks
very much in advance.


Excuse the silly question - but why not install phpmyadmin .

IMS you only need to change one or two lines in the config file for it
to work .
Jul 23 '05 #2
I noticed that Message-ID:
<MP************************@no-cancel.newsreader.com> from SOR contained
the following:
How can I insert rows
of binary data (jpegs) into my table through the command prompt? Thanks
very much in advance.


Excuse the silly question - but why not install phpmyadmin .


Even sillier, why put images in the database in the first place?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 23 '05 #3
> Even sillier, why put images in the database in the first place?


Perhaps it isn't suitable in this particular scenario, but if you are likely
to have thousands of images, isn't there a limit to the number of files you
can put into a particular directory?

I store photos in a database with no ill effects so far. No one has been
able to convince me one is better than the other - perhaps you can?
Jul 24 '05 #4
On Sat, 23 Jul 2005 18:35:22 GMT, Marcus <Ju********@aol.com> wrote:
Quick question... I am storing jpegs as blobs in a mysql table, which is
fine on my live server because I am just uploading them using phpmyadmin
(I am working with a small number of images that will rarely change and
thus do not have a need for an upload script). My problem is I do all
my testing on my local host where I do not have phpmyadmin, I do
everything with mysql through the command prompt. How can I insert rows
of binary data (jpegs) into my table through the command prompt? Thanks
very much in advance.


Look in the MySQL manual under "String functions":

"
LOAD_FILE(file_name)

Reads the file and returns the file contents as a string. The file must be
located on the server, you must specify the full pathname to the file, and you
must have the FILE privilege. The file must be readable by all and be smaller
than max_allowed_packet bytes.

If the file doesn't exist or cannot be read because one of the preceding
conditions is not satisfied, the function returns NULL.

mysql> UPDATE tbl_name
SET blob_column=LOAD_FILE('/tmp/picture')
WHERE id=1;
"

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 24 '05 #5
I noticed that Message-ID:
<42***********************@news.optusnet.com.au> from Michael Phipps
contained the following:
Even sillier, why put images in the database in the first place?

Perhaps it isn't suitable in this particular scenario, but if you are likely
to have thousands of images, isn't there a limit to the number of files you
can put into a particular directory?


Not that I'm aware of.
I store photos in a database with no ill effects so far. No one has been
able to convince me one is better than the other - perhaps you can?


I'm not saying you will have any ill effects (though I'm sure there
would be if the number of images got very large). It's just that there
is little or no benefit in storing images themselves. You can't search
on them or sort on them. However, with file names I can do all these
things. With sensible naming you can fetch your pictures in all sorts
of ways. Additionally the same picture can be accessed by any number of
database records without the overhead of storing it n number of times.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 24 '05 #6
On Sun, 24 Jul 2005 15:59:00 +0100, Geoff Berrow <bl******@ckdog.co.uk> wrote:
It's just that there
is little or no benefit in storing images themselves.
The main benefits of storing the images in the database are:

(1) Single point of backup.
(2) Atomic operations on the image data in the same way as for the other
associated data. (This also applies to the backup point, since if you have
database + filesystem, it's harder to get a consistent backup of the two).
You can't search
on them or sort on them. However, with file names I can do all these
things.
With the image in or out of the database, you can search and sort on whatever
you like. Putting it in the filesystem doesn't make a difference here.
With sensible naming you can fetch your pictures in all sorts
of ways. Additionally the same picture can be accessed by any number of
database records without the overhead of storing it n number of times.


There's no need to store the same image multiple times in a normalised
database.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 24 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kirby Urner | last post by:
I've been testing the Cookbook example 8.6 (2002 edition) re using cPickle to insert and retrieve BLOBs from mySQL, using Python's MySQLdb module. When I try to cPickle.loads(blob), I get an...
0
by: Ole Hansen | last post by:
Hi, Is it at all possible to insert BLOBs using the Array Interface? Today I have an application using the array interface. It works fine but so far I haven't been using BLOBs. I insert...
1
by: picaza | last post by:
hi, does anyone have a perl example of loading blobs from either a bin file or an input stream? much thanks, peter
2
by: Ike | last post by:
I have blob fields in some tables - never more than one field in any table, and never where a blob can be > 64k. I have inherited the code for this project from someone else, and was considering...
1
by: Jesse Wolgamott | last post by:
I've seen plenty of posts regarding the estimation of table size, usually in the processing of planning for server storage needs. Well, I've got a different problem. I need to know how much data...
7
by: Howard Lowndes | last post by:
My situation is that I am interacting PHP 4.1.2 to PostgreSQL 7.2.2 I have no difficulty inserting and managing BLOBs into the Large Object system table, and I have a user table called images...
7
by: Nilabhra Banerjee | last post by:
Hi, I am still not sure whether the BLOBS are actually stored in the database or they have the pointer to the database for that file in the filesystem. If I remove the files (sources) for BLOBS...
0
by: Bing | last post by:
Hi there, I am using the DB2 universal JDBC driver type 4 to insert BLOBs into a DB2 database. The Method I used for supplying the BLOB data value is setBinaryStream(). Everything works fine as...
2
by: Jerry LeVan | last post by:
Hi, I am just getting into large objects and bytea "stuff". I created a small db called pictures and loaded some large objects and then tried to do a restore. Here is how I got the dump. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.