binary data storage 
Author Message
 binary data storage

Hi,

Let's say we have 100 MB of binary file (for example, a zip file). How
could we store this file in PostgreSQL? Which datatype could we use and
how do we insert it?

Best regards,

--

Devrim GUNDUZ




Web : http://www.***.com/
------------------------------------------------------------------

---------------------------(end of broadcast)---------------------------



Mon, 20 Sep 2004 14:49:54 GMT
 binary data storage

Hi Martin,
        I discourage you to use the large object data type for a file of such
dimensions... It would be better for you to store in the db the filename
and the path to the file itself.
        However you can find the large object you've inserted in your data
directory (subdirectory base/oid of your database/).

Bye,
--

---------------------------
Programmer & System Administrator - Edistar srl

Il gio, 2002-04-04 alle 14:07, Martn Marqus ha scritto:

Quote:

> > Hi Marin,


> > > search for "large objects" in the Programmer's Guide (
> > > http://www.***.com/ #7.2 )

> > > in your case Large Objects (chapter 2 from the Programmer's Guide) may be
> > > more appropriate than binary strings (chapter 3.4 from the User's Guide)

> > Thanks alot. Also searched php manual and wrote the following simple code:

> > <?
> >       $conn = Pg_Connect (......);
> >     pg_exec ($conn, "begin");
> >     $oid = pg_locreate ($conn);
> >     echo ("$oid\n");
> >     $handle = pg_loopen ($conn, $oid, "w");
> >     echo ("$handle\n");
> >     pg_loimport ("/etc.tar.gz");
> >     pg_lowrite ($handle, "/etc.tar.gz");

> This is something that confuses me:
> What does pg_loimport do, and what does pg_lowrite do?

> >     pg_loclose ($handle);
> >     pg_exec ($conn, "commit");
> > ?>

> Another question I have about using PHP and PostgreSQL Large Objects, is that
> in no place there is a reference to where the lo will be stored?

> I mean, where will /etc.tar.gz be stored in the Database?

> Saludos... :-)

> --
> Porqu usar una base de datos relacional cualquiera,
> si pods usar PostgreSQL?
> -----------------------------------------------------------------

> Programador, Administrador, DBA |       Centro de Telematica
>                        Universidad Nacional
>                             del Lit{*filter*}
> -----------------------------------------------------------------

> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------



Mon, 20 Sep 2004 23:54:19 GMT
 binary data storage

Quote:

> I still don't get it.
> If I use pg_lo* to put my binary data in the database, where will it be,
> always talking about the structure of the database.
> Example:
> A table with 5 fields, and one is of type oid, and I want to insert data (a
> new row to the table) in which I have a binary file to put in the oid field.

> And how about if I have more then one oid field?

> I see no specification on which field the binary object will be inserted.

Here's the way it works:

You create the LO with lo_create() or lo_import().  These give you an
OID that is your "handle" for getting at the LO data.  You then store
the OID in a column of type 'oid' in one or more of your tables.

To retrieve the LO data, fetch the OID from the table it lives in, and
use lo_open() and lo_read() to fetch the actual data.

Make sense?

-Doug
--
Doug McNaught       Wireboard Industries      http://www.wireboard.com/

      Custom software development, systems and network consulting.
      Java PostgreSQL Enhydra Python Zope Perl Apache Linux BSD...

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Tue, 21 Sep 2004 00:13:47 GMT
 binary data storage
On Thu, 4 Apr 2002 12:36:42 +0300

Quote:

> ----- Original Message -----
> From: "Devrim GUNDUZ"

> > Hi,

> > Let's say we have 100 MB of binary file (for example, a zip file). How
> > could we store this file in PostgreSQL? Which datatype could we use and
> > how do we insert it?

> search for "large objects" in the Programmer's Guide

You could also use a column with datatype "bytea", and the libpq
function PQescapeBytea().

Cheers,

Neil

--

PGP Key ID: DB3C29FC

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command



Tue, 21 Sep 2004 00:35:32 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. binary data storage using file index

2. binary data storage

3. Binary Data Storage?

4. Saving Binary Data to a Paradox Binary Field via Code

5. SQL Server2000 storage binary or dictionary interpreted?

6. Binary large object storage for text

7. Physical storage of binary objects (BLOB)

8. Binary storage

9. Physical storage of binary objects

10. Binary large object storage for text

11. Binary Data in SQL 2000/Conver to Bitmap Data For Data Grid View

12. Data storage (data warehousing related) research papers?


 
Powered by phpBB® Forum Software