Re: Copy entire file as one field

From: "Warren Massengill" <warrenmassengill(at)hotmail(dot)com>
To: olly(at)lfix(dot)co(dot)uk
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Copy entire file as one field
Date: 2002-12-03 19:48:52
Message-ID: F147VJpjc0D543TuylJ0000eadd@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

My database is pg, the table is mail.
The small text files are in /home/kelly/message/.
The bash shell script is merge.

Somehow I failed to translate your instructions...

-----------------------------------------------------
#!/bin/bash

for f in `ls /home/kelly/message*`
do
psql -d pg -c "INSERT INTO mail (message)
VALUES ('`cat $f`')"
done

----------------------------------------------------
[kelly(at)localhost message]$ merge
merge: not enough arguments
merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3
merge aborted

----------------------------------------------------
Thanks,
Warren

>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: [NOVICE] Copy entire file as one field
>Date: 28 Nov 2002 07:43:12 +0000
>
>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
><< signature.asc >>

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Warren Massengill 2002-12-03 19:55:44 Re: Copy entire file as one field
Previous Message Ron Johnson 2002-12-03 17:38:32 Re: its really SLOW!!!!!