Re: How to store text files in the postgresql?

From: Florian Weimer <fw(at)deneb(dot)enyo(dot)de>
To: DimitryASuplatov <genesup(at)gmail(dot)com>
Cc: rod(at)iol(dot)ie, pgsql-general(at)postgresql(dot)org
Subject: Re: How to store text files in the postgresql?
Date: 2009-06-07 09:10:57
Message-ID: 87y6s41k9q.fsf@mid.deneb.enyo.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

* DimitryASuplatov:

> I`ve also worked out how to do this simply from bash
>
> ./bin/psql mypdb <<EOF
> insert into pdb values ('`cat /file/name`');
> EOF

This doesn't work if the file contains embedded "'" characters (and
backslashes and NULs are also problematic). You will also get errors
if the file encoding does not match the database encoding.

You probably should use a BYTEA column and a little Perl script which
uses bind_param to specify a type of PG_BYTEA for the parameter.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Johan Nel 2009-06-07 11:18:25 Re: How to store text files in the postgresql?
Previous Message Craig Ringer 2009-06-07 05:38:58 Re: limit table to one row