Attached are large object read and write functions I wrote based on
information I gleened from the DBD::Pg install test script.
They read and write to buffers rather than files because my
information wasn't comming from a file and wasn't going to one. However
if you need the data to go to a file you can either open a file handle
yourself in these methods and read into a scalar or write out from one, OR
you can scan the test.pl file in the DBD::Pg install to see how to use the
proper file based read and write Pg calls.
M. Tavasti <tawz@nic.fi> wrote:
>
> How do I handle large objects in DBD:Pg (perl DBI interface to
> postgresql)?
>
> I've tried to do like this, but not successfull, it looks like there
> is no data inserted. I tried to see in psql is there something, doing
> SELECT lo_export(data,"/tmp/foofaa.txt") from foofaa where id=XXXX;
>
> $obj_ins = $dbh->prepare(q{
> INSERT INTO foofaa
> (id,entry,data)
> VALUES
> (?,?,?)});
>
> $obj = $dbh->func("./$dir/obj.txt", 'lo_import');
> $obj_ins->execute($id,$ent,$obj);
>
>
>
>
> Manual page of DBD:Pg if confusing for lo_export:
>
> $ret = $dbh->func($lobjId, 'lo_export');
>
> Exports a large object into a Unix file. Returns
> false upon failure, true otherwise.
>
> To what file....
>
> Any help welcome.
>
>