Re: flat file database to postgres - Mailing list pgsql-sql

From Tatsuo Ishii
Subject Re: flat file database to postgres
Date
Msg-id 20040316.230400.39151407.t-ishii@sra.co.jp
Whole thread Raw
In response to Re: flat file database to postgres  (Frank Finner <postgresql@finner.de>)
List pgsql-sql
> On Tue, 16 Mar 2004 12:33:57 -0000 (GMT) noor@cs.man.ac.uk sat down, thought long and then wrote:
>
> >
> > Hi
> >
> > Does anybody know how to export data from a flatfile (using perl) database
> > to postgres?
> >
> > Thanks
>
> If it is some kind of CSV (text with separators) you could use DBD::CSV for reading and DBD::Pg for
> writing. Or you read the file with Perl´s standard functions, treat the data to be
> PostgreSQL-insert-query-compatible (regarding apostrophes for example) and then use DBD::Pg (that´s
> what I usually do). If you have some kind of DBase files, you can use DBD::XBase.

I wrote a user defined C function which read a file and returns it.

test=# SELECT * FROM exttable('/etc/group', ':') AS g(gname TEXT, dummy TEXT, gid INTEGER, gmembers TEXT) LIMIT
10;gname | dummy | gid |    gmembers      
--------+-------+-----+-----------------root   | x     |   0 | rootbin    | x     |   1 | root,bin,daemondaemon | x
|  2 | root,bin,daemonsys    | x     |   3 | root,bin,admadm    | x     |   4 | root,adm,daemontty    | x     |   5 |
disk  | x     |   6 | rootlp     | x     |   7 | daemon,lpmem    | x     |   8 | kmem   | x     |   9 |  
(10 rows)

Of course this kind of function could be dangerous if you
thoughtlessly use it. Anyway I could post it if there's enough
interest.
--
Tatsuo Ishii


pgsql-sql by date:

Previous
From: "Luis P Caamano"
Date:
Subject: Can statement_timeout emulated NOWAIT?
Next
From: Tom Lane
Date:
Subject: Re: Can statement_timeout emulated NOWAIT?