Thread: loading files into tables

loading files into tables

From
"Pau Marc Munoz Torres"
Date:
Hi

 I'm an ex-mysql user, i know there was a sentence in mysql that was

      load data local infile "somefile.txt" into table "sometable;

I'm trying to do something similar in postgresql, can someone help me?

Thanks

Pau

--
Pau Marc Muñoz Torres

Laboratori de Biologia Computacional  
Institut de  Biotecnologia   i Biomedicina Vicent Villar                                    
Universitat Autonoma de Barcelona
E-08193 Bellaterra (Barcelona)
              
telèfon: 93 5812807
Email : paumarc.munoz@bioinf.uab.cat

Re: loading files into tables

From
Raymond O'Donnell
Date:
On 04/02/2008 15:29, Pau Marc Munoz Torres wrote:

> I'm trying to do something similar in postgresql, can someone help me?

You're probably looking for the COPY command:

   http://www.postgresql.org/docs/8.3/static/sql-copy.html

Ray.


---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

Re: loading files into tables

From
Ivan Sergio Borgonovo
Date:
On Mon, 4 Feb 2008 16:29:51 +0100
"Pau Marc Munoz Torres" <paumarc@gmail.com> wrote:

> Hi
>
>  I'm an ex-mysql user, i know there was a sentence in mysql that was
>
>       load data local infile "somefile.txt" into table "sometable;
>
> I'm trying to do something similar in postgresql, can someone help
> me?

Are you referring to something like
http://www.postgresql.org/docs/8.1/static/sql-copy.html
or something like:
http://archives.postgresql.org/pgsql-php/2004-02/msg00008.php
?


--
Ivan Sergio Borgonovo
http://www.webthatworks.it


Re: loading files into tables

From
Dimitri Fontaine
Date:
Hi,

Le lundi 04 février 2008, Pau Marc Munoz Torres a écrit :
>  I'm an ex-mysql user, i know there was a sentence in mysql that was
>
>       load data local infile "somefile.txt" into table "sometable;
>
> I'm trying to do something similar in postgresql, can someone help me?

COPY manual entry as already been pointed to you, let me introduce pgloader
project in case you would need to edit the data on-the-fly (ETL):
  http://pgloader.projects.postgresql.org/
  http://pgfoundry.org/projects/pgloader/
  http://pgsql.tapoueh.org/site/html/pgloader/index.html

More to come on this last link :)
--
dim

Attachment

Re: loading files into tables

From
"Pau Marc Munoz Torres"
Date:
Ok

 I'm tryint to execute

     copy local from "/path" with delimiter "\t";

and I get the following errors

  ERROR: must be superuser to COPY to or from a file.

 Can I do something similar to it without being superuser?

 for a Tab delimiter, should i use "\t" character?

Thanks

Pau

2008/2/4, Dimitri Fontaine <dfontaine@hi-media.com>:
Hi,

Le lundi 04 février 2008, Pau Marc Munoz Torres a écrit :
>  I'm an ex-mysql user, i know there was a sentence in mysql that was
>
>       load data local infile "somefile.txt" into table "sometable;
>
> I'm trying to do something similar in postgresql, can someone help me?

COPY manual entry as already been pointed to you, let me introduce pgloader
project in case you would need to edit the data on-the-fly (ETL):
  http://pgloader.projects.postgresql.org/
  http://pgfoundry.org/projects/pgloader/
  http://pgsql.tapoueh.org/site/html/pgloader/index.html

More to come on this last link :)
--
dim




--
Pau Marc Muñoz Torres

Laboratori de Biologia Computacional  
Institut de  Biotecnologia   i Biomedicina Vicent Villar                                    
Universitat Autonoma de Barcelona
E-08193 Bellaterra (Barcelona)
              
telèfon: 93 5812807
Email : paumarc.munoz@bioinf.uab.cat

Re: loading files into tables

From
Ivan Sergio Borgonovo
Date:
On Mon, 4 Feb 2008 17:21:00 +0100
"Pau Marc Munoz Torres" <paumarc@gmail.com> wrote:

> Ok
>
>  I'm tryint to execute
>
>      copy local from "/path" with delimiter "\t";
>
> and I get the following errors
>
>   ERROR: must be superuser to COPY to or from a file.
>
>  Can I do something similar to it without being superuser?
>
>  for a Tab delimiter, should i use "\t" character?

The message should be longer and actually explain what to do.

you can \copy or copy from stdin.

You could find this helpful:

http://www.postgresql.org/docs/techdocs.15

--
Ivan Sergio Borgonovo
http://www.webthatworks.it