Re: Execute A String of Query - Mailing list pgsql-admin

From Daniel Andersen
Subject Re: Execute A String of Query
Date
Msg-id S38FJyXde2kqkOzV8Q30000443e@smtp02.iprimus.net.au
Whole thread Raw
In response to Execute A String of Query  ("lonh SENG" <slonh@camgsm.com.kh>)
List pgsql-admin
>     I am really new to Postgres. But I am familiar with SQL Server.
>
>     I want import data from delimiter file.
>     How can I do this?
>     My delimiter file is as following:
>
> Regards,
>
> lonh

I'm not sure if theres a neater solution out there, but I usually just pipe
it through a one liner perl script and then back into psql, sorta like

cat filename|perl -ne 's/\|/,/g; chop $_; print "insert into tablename values
($_);\n"'|psql databasename

under the bash shell. Of course this all gets a bit messy if there are
strings involved, but works nicely for numerical data. although the example
given suggests you have access to the original database, in which case simply
pg_dumping it is a much easier solution :)
    Daniel

pgsql-admin by date:

Previous
From: Mohd Toha Taifor
Date:
Subject: Dynamic columns
Next
From: Stephan Szabo
Date:
Subject: Re: Execute A String of Query