Re: Use PSQLFS for photo storage

From: Jason Long <mailing(dot)list(at)supernovasoftware(dot)com>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Use PSQLFS for photo storage
Date: 2009-01-14 00:43:06
Message-ID: 496D351A.9010705@supernovasoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sam Mason wrote:
> On Tue, Jan 13, 2009 at 06:22:34PM -0600, Jason Long wrote:
>
>> Sam Mason wrote:
>>
>>> You'd need to generate the SQL somehow; if you know python it's probably
>>> a pretty easy 20 or 30 lines of code to get this working.
>>>
>
>
>> *Never used Python or Perl. I use primarily Java. I was thinking of
>> doing something like
>>
>> *INSERT INTO pictures (filename,data) VALUES
>> ('filename','/path/to/my/image/img0009.jpg');
>>
>
> If you're OK with using large objects, instead of "bytea"s, you can use
> the lo_import function. You'd do something like:
>
> CREATE TABLE pics (
> path TEXT PRIMARY KEY,
> data OID
> );
>
> INSERT INTO pics (path,data)
> SELECT path, lo_import(path)
> FROM (VALUES ('/path/to/my/image/img0009.jpg')) x(path);
>
> This assumes that the files are accessable to the database server (i.e.
> the paths are relative to the server daemon, not the psql command line
> or whatever JDBC app you're driving this from).
>
> Does that help any more?
>
>
> Sam
>
>
*They are on the server. I would rather use bytea. Is it possible to
import them as large objects and then use SQL to convert them to bytea?*

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-01-14 00:56:42 Re: Use PSQLFS for photo storage
Previous Message Sam Mason 2009-01-14 00:37:05 Re: Use PSQLFS for photo storage