Re: Importing/Exporting

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Nathan Hill <cmsu_tech(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Importing/Exporting
Date: 2002-07-31 23:46:11
Message-ID: 1028159172.22663.65.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2002-07-31 at 22:39, Nathan Hill wrote:
> I am new to doing DBA activities. I am trying to
> write a bash script that will copy the value of a
> specific field within a table in a postgres database
> on one server and import the value of that field into
> a table in a mysql database on a separate server. I
> am not real familiar with sql statements yet so I was
> hoping that someone could give me some advice.
>
> My initial thoughts would be to copy the output of the
> select statement to a file, copy the value that I need
> from the file to a variable, then import that variable
> into the appropriate field in the mysql database.
> Where I am getting hung up is trying to export the
> value of a specific field to a file.
>
> Is there an easier way of doing this?

If you want one value only, you can just store it in a variable rather
than a file:

myvar=`psql -d mydatabase -A -t -c "SELECT field1 FROM table1 WHERE field2 = 'x' LIMIT 1"`
mysql -e "UPDATE table2 SET field2 = '$myvar' ..." ...

--
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
========================================
"And why call ye me, Lord, Lord, and do not the things
which I say?" Luke 6:46

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sanjeev Rathore 2002-08-01 00:14:50 image
Previous Message Nathan Hill 2002-07-31 21:39:07 Importing/Exporting