ph0enix has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks
I want to store some binary data in sql database (actually postgresql) produced by Storable::nfreeze(). How can I do it?
Test table have following structure
Attribute | Type | Modifier -----------+------------------------+---------- pkey | character varying(255) | not null pvalue | bytea | Index: demo_pkey
Following test code fails with error 'Unterminated quoted string at ...' for line with execute call.
#!/usr/bin/perl -w use strict; use Storable qw(nfreeze thaw); use DBI; use DBD::Pg; # database settings my $db_name = 'unicode'; my $db_host = 'localhost'; my $db_user = 'elric'; my $db_pass = 'test01'; my $dbh = DBI->connect("dbi:Pg:dbname=$db_name;host=$db_host;", "$db_user", "$db_pass"); my $test = { 'ahoj svete...', [ 1, 23, 'ttt' ], }; my $sth = $dbh->prepare("insert into demo values (?, ?)"); $sth->execute('test', nfreeze($test)); $dbh->disconnect(); exit 0;
I need to have similar functionality like MLDBM module, but for sql database. The modules Tie::RDBM, Tie::MLDBM looks buggy for me.
How can I solve this. What I'm doing wrong? or is there already preset other module for doing this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: postgresql: store binary data?
by diotalevi (Canon) on Dec 02, 2002 at 14:01 UTC | |
by ph0enix (Friar) on Dec 02, 2002 at 14:40 UTC | |
|
Re: postgresql: store binary data?
by djantzen (Priest) on Dec 02, 2002 at 13:53 UTC | |
|
Re: postgresql: store binary data?
by rdfield (Priest) on Dec 02, 2002 at 13:50 UTC |