NAME
Pg::hstore - Perl extension for encoding/decoding postgresql's hstore data type.
SYNOPSIS
use Pg::hstore;
...
my $row = $sth->fetchrow_hashref; #Getting row from DB
print "hstore data: ", $row->{addinfo}, "\n";
my $addinfo = Pg::hstore::decode($row->{addinfo}); #Decoding into perl hashref
#now $addinfo is 1-level hash ref with key->value
print "addinfo->'full_name' = ", $addinfo->{full_name}, "\n";
...
#Updating hstore. This type of updating can wipe other process work on addinfo field
$addinfo->{full_name} = "John the ripper";
$dbh->do("update users set addinfo=? where id=?", undef,
Pg::hstore::encode($addinfo), 123);
DESCRIPTION
decode(string)
Decode given HSTORE value. NULL values will be converted to Perl undef; NULL or empty keys will be ignored. Returns hash ref with key => value pairs. Can return undef on internal error. Keys and values will have same UTF8 flag as incoming string.
encode(hashref)
Encodes given hash ref to HSTORE-format string. undef values will be converted to NULL. Empty or undef keys will be ignored. Returns hstore-serialized string. Can return undef on internal error. String will have UTF8 flag ON if any of hashref values have it.
EXPORT
None by default. Can export hstore_encode and hstore_decode subs:
use Pg::hstore qw/hstore_encode hstore_decode/;
BUGS
None known. Feel free to clone/contribue from https://bitbucket.org/PSIAlt/p5-pg-hstore
COPYRIGHT AND LICENSE
Copyright (C) 2011 by Alt
----------------------------------------------------------------------------
"THE BEER-WARE LICENSE"
As long as you retain this notice you can do whatever you want with this stuff.
If we meet some day, and you think this stuff is worth it, you can buy me a beer
in return.
----------------------------------------------------------------------------