Re: Copy entire file as one field - Mailing list pgsql-novice

From Oliver Elphick
Subject Re: Copy entire file as one field
Date
Msg-id 1038469391.13294.319.camel@linda.lfix.co.uk
Whole thread Raw
In response to Copy entire file as one field  ("Warren Massengill" <warrenmassengill@hotmail.com>)
List pgsql-novice
On Thu, 2002-11-28 at 00:40, Warren Massengill wrote:
> How can I copy several hundred small text files into a database, each file
> going into a field called 'message' and becomming one record (with or
> without other fields) using psql?

A bit of shell scripting:

for f in `ls small_file*`
do
    psql -d mydatabase -c "INSERT INTO mytable (message)
                 VALUES ('`cat $f`')"
done


--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "The earth is the LORD'S, and the fullness thereof; the
      world, and they that dwell therein."       Psalms 24:1

Attachment

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: DB dump problems
Next
From: HK
Date:
Subject: 'now' doesnt seem to work in stored procedure