Re: describe table (from perl)

Поиск
Список
Период
Сортировка
Искать
От
Greg Sabino Mullane
Тема
Re: describe table (from perl)
Дата
в 20:00:13
Msg-id
511e2b0ebbd2fd6f1cfb637ec3a8934d@biglumber.com
Ответ на
Список
Дерево обсуждения
describe table (from perl) "Celia McInnis" <celia@drmath.ca>
Re: describe table (from perl) "Greg Sabino Mullane" <greg@turnstep.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> What's the easiest way to have perl (using the DBI module) extract table
> information? I need to be able to extract column names and types. (Something
> like what is given by the MySql "DESCRIBE mytable" command).

You want the column_info() method: it's documented in DBI and in DBD::Pg.
Usage is something like this:

$table = "foobar";
$sth = $dbh->column_info('','',$table,'');
$info = $sth->fetchall_arrayref({});
print Dumper $info;

In particular, you want the COLUMN_NAME and TYPE_NAME attributes. Also look
at the "pg_type" attribute, which gives a friendlier version of TYPE_NAME.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200505161856
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCiSWwvJuQZxSWSsgRAsQCAJ9ovbiDS9Wej34z0BbfKwg81lQCgQCgs+cF
HCnypGWqGWE1YAU1y37zsZg=
=Mje/
-----END PGP SIGNATURE-----


В списке pgsql-novice по дате отправления
От: Sean Davis
Дата:
От:
Дата:
FAQ