Re: flat file database to postgres
От | Tatsuo Ishii |
---|---|
Тема | Re: flat file database to postgres |
Дата | |
Msg-id | 20040316.230400.39151407.t-ishii@sra.co.jp обсуждение исходный текст |
Ответ на | Re: flat file database to postgres (Frank Finner <postgresql@finner.de>) |
Список | 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 по дате отправления: