Re: Multiple COPYs - Mailing list pgsql-general

From Douglas McNaught
Subject Re: Multiple COPYs
Date
Msg-id m2wtotukcu.fsf@Douglas-McNaughts-Powerbook.local
Whole thread Raw
In response to Multiple COPYs  (rasdj@frontiernet.net)
List pgsql-general
rasdj@frontiernet.net writes:

> Hello,
>
> Having a great time with PG - ported an erp from oracle and db2. First
> I tried MySql but choked somewhere in the 900 table region. I have a
> python script to translate the syntax and it loads about 2000 tables.
>
> Now I want to COPY my dumps - I have 1 data dump for each table. Any
> tips on what to use so that I can read the file name into a variable
> and pass it as the file name in the COPY command and have one script
> load all my tables?

Should be pretty easy from the shell, something like (untested):

for f in *.sql; do
  tablename=`basename $f .sql`
  psql -c "\\copy $tablename from $f" mydatabase
done

-Doug

pgsql-general by date:

Previous
From: Douglas McNaught
Date:
Subject: Re: Help: chinese character set support (EUC_TW to/from BIG5 conversion)
Next
From: Bruce Momjian
Date:
Subject: Change to make strings SQL-standard