Op 08-10-15 om 14:10 schreef Graeme B. Bell:
On 08 Oct 2015, at 13:50, Bram Van Steenlandt <b...@diomedia.be> wrote:
1. The part is "fobj = lobject(db.db,0,"r",0,fpath)", I don't think there is
anything there
Re: lobject
http://initd.org/psycopg/docs/usage.html#large-objects
"Psycopg large object support *efficient* import/export with file system files
using the lo_import() and lo_export() libpq functions.”
See *
I was under the impression they meant that the lobject was using
lo_import and lo_export.
I can't seem to find how to use lo_import en export, I searched google
and came to the conclusion the lobject was the way to go.
>>> x.lo_import()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'psycopg2._psycopg.connection' object has no attribute
'lo_import'
>>> from psycopg2.extensions import lo_importTraceback (most recent
call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name lo_import
Also:
http://initd.org/psycopg/docs/connection.html
|lobject|([/oid/[, /mode/[, /new_oid/[, /new_file/[, /lobject_factory/]]]]])
Return a new database large object as a |lobject|
<http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.lobject>
instance.
See Access to PostgreSQL large objects
<http://initd.org/psycopg/docs/usage.html#large-objects> for an
overview.
Parameters:
* *oid* – The OID of the object to read or write. 0 to create a
new large object and and have its OID assigned automatically.
* *mode* – Access mode to the object, see below.
* *new_oid* – Create a new object using the specified OID. The
function raises |OperationalError|
<http://initd.org/psycopg/docs/module.html#psycopg2.OperationalError>
if the OID is already in use. Default is 0, meaning assign a new
one automatically.
* *new_file* – The name of a file to be imported in the the
database (using the |lo_import()|
<http://www.postgresql.org/docs/current/static/lo-interfaces.html#LO-IMPORT>
function)
* *lobject_factory* – Subclass of |lobject|
<http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.lobject>
to be instantiated.
lobject seems to default to string handling in Python
That’s going to be slow.
Try using lo_import / export?
Graeme Bell