sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Josh Close's Avatar

COPY FROM STDIN not in local file


Question posted by: Josh Close (Guest) on November 23rd, 2005 02:21 AM
Is there a way to do COPY FROM STDIN from sql? So, remotely I could
run the copy command and somehow push the info over instead of having
it on the server.

-Josh

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

2 Answers Posted
Bruce Momjian's Avatar
Guest - n/a Posts
#2: Re: COPY FROM STDIN not in local file


You have to use psql's \copy.

---------------------------------------------------------------------------

Josh Close wrote:[color=blue]
> Is there a way to do COPY FROM STDIN from sql? So, remotely I could
> run the copy command and somehow push the info over instead of having
> it on the server.
>
> -Josh
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>[/color]

--
Bruce Momjian | http://candle.pha.pa.us
Join Bytes! | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to Join Bytes!

Josh Close's Avatar
Guest - n/a Posts
#3: Re: COPY FROM STDIN not in local file

On Wed, 29 Sep 2004 14:40:34 -0500, Josh Close <narshe@gmail.com> wrote:[color=blue]
> Is there a way to do COPY FROM STDIN from sql? So, remotely I could
> run the copy command and somehow push the info over instead of having
> it on the server.[/color]

For those who are curious, I found a php implementation of this. It
uses the postgre put_line function.

<?php
$conn = pg_pconnect("dbname=foo");
pg_query($conn, "create table bar (a int4, b char(16), d float8)");
pg_query($conn, "copy bar from stdin");
pg_put_line($conn, "3\thello world\t4.5\n");
pg_put_line($conn, "4\tgoodbye world\t7.11\n");
pg_put_line($conn, "\\.\n");
pg_end_copy($conn);
?>

-Josh

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

 
Not the answer you were looking for? Post your question . . .
196,932 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,932 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors