Re: Bytea and perl

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: Bytea and perl
Дата
Msg-id a44a2dc421934081dccf4b50dc04001e@biglumber.com
обсуждение исходный текст
Ответ на Bytea and perl  (Sean Davis <sdavis2@mail.nih.gov>)
Ответы Re: Bytea and perl
Список pgsql-novice
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> What is the accepted way of inserting a binary string into
> a bytea column in perl?

It's pretty much as you described. Here's an example, modified
from the test suite:

use DBD::Pg qw(:pg_types);
...
my $sth = $dbh->prepare(qq{INSERT INTO dbd_pg_test (id,bytetest) VALUES (?,?)});

$sth->bind_param(2, undef, { pg_type => DBD::Pg::PG_BYTEA });

$sth->execute(400, 'aa\\bb\\cc\\\0dd\\');

Other options include storing just a filename, or base-64 encoding
everything and storing it as a text. I tend to prefer the latter
more often than not, as the encode/decode goes very quickly on
most modern computers.

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

iD8DBQFEIhEBvJuQZxSWSsgRAvAuAKDXEg6i+aykLuDeYpPCYCF+5XosNACfd/hZ
PR8cSm0/9NCJVInn+yEBpsU=
=jfTz
-----END PGP SIGNATURE-----



В списке pgsql-novice по дате отправления:

Предыдущее
От: Sean Davis
Дата:
Сообщение: Bytea and perl
Следующее
От: Andrea
Дата:
Сообщение: Problems using PostgreSQL command line tools