Skip site navigation (1) Skip section navigation (2)

Re: Copy entire file as one field

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Warren Massengill <warrenmassengill(at)hotmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Copy entire file as one field
Date: 2002-11-28 07:43:12
Message-ID: 1038469391.13294.319.camel@linda.lfix.co.uk (view raw or flat)
Thread:
Lists: 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(dot)Elphick(at)lfix(dot)co(dot)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

In response to

pgsql-novice by date

Next:From: HKDate: 2002-11-28 11:36:43
Subject: 'now' doesnt seem to work in stored procedure
Previous:From: etsuko shimabukuroDate: 2002-11-28 04:50:47
Subject: user defined function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group