From: Billy G. A. <bal...@us...> - 2001-10-17 06:38:24
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv8437 Modified Files: README pgconnection.c Log Message: 17OCT2001 bga Fixed some problems with the large object handling. --- Added the lo_export method, which was missing. Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** README 2001/10/13 20:46:40 1.16 --- README 2001/10/17 06:38:20 1.17 *************** *** 81,86 **** pymemstrdup.c - the C code implementing a version of strdup() that uses Python's heap for the needed memory ! PgSQL.py - the module that implements the Python DB-API 2.0 compliant interface to PostgreSQL setup.py - Distutil setup file for building and installing pyPgSQL --- 81,89 ---- pymemstrdup.c - the C code implementing a version of strdup() that uses Python's heap for the needed memory ! pyPgSQL/__init__.py - the initialization code for the pyPgSQL package. ! pyPgSQL/PgSQL.py - the module that implements the Python DB-API 2.0 compliant interface to PostgreSQL + pyPgSQL/libpq - the package for the libpq module. + pyPgSQL/libpq/__init__.py - the initialization code for the libpq package. setup.py - Distutil setup file for building and installing pyPgSQL *************** *** 510,513 **** --- 513,517 ---- lo_import - Import a file as a PostgreSQL large object, returning a PgLargeObject. + lo_export - export a PostgreSQL large object to a file. lo_unlink - Removes a PostgreSQL large object from the database. trace - Enable tracing of frontend/backend communications. *************** *** 771,775 **** Note: See the PostgreSQL C API documentation for details. ! 2.2.19 lo_unlink ---------------- --- 775,794 ---- Note: See the PostgreSQL C API documentation for details. ! 2.2.19 lo_export ! ---------------- ! ! Syntax: c.lo_export(oid, filename) ! ! Returns: A PgLargeObject ! ! Description: Exports a PostgreSQL large object, represented by oid, to a ! file named 'filename'. This method implements the lo_import ! function. ! ! Exceptions: InterfaceError, OperationalError, TypeError ! ! Note: See the PostgreSQL C API documentation for details. ! ! 2.2.20 lo_unlink ---------------- *************** *** 781,785 **** Exceptions: InterfaceError, IOError, TypeError ! 2.2.20 trace ------------ --- 800,804 ---- Exceptions: InterfaceError, IOError, TypeError ! 2.2.21 trace ------------ *************** *** 794,798 **** Note: See the PostgreSQL C API documentation for details. ! 2.2.21 untrace -------------- --- 813,817 ---- Note: See the PostgreSQL C API documentation for details. ! 2.2.22 untrace -------------- *************** *** 1327,1330 **** --- 1346,1356 ---- cnx.query('insert into table values(%s)', (list,)) + + -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + When working with PostgreSQL large object, you MUST be in a transaction. + The code will try to ensure that a transcation is active while working with + large object (i.e. lo_open will start a transaction if necessary. lo_close + will end the transaction if it determines that lo_open started one.) -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pgconnection.c 2001/10/13 20:40:35 1.14 --- pgconnection.c 2001/10/17 06:38:21 1.15 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 17OCT2001 bga Added the lo_export() method. It was overlooked in the | + | original code. | | 13OCT2001 bga Added support for the pickling of PgConnection objects. | | In particular, a hidden method was added to return the | *************** *** 956,961 **** --- 958,989 ---- } + /*--------------------------------------------------------------------------*/ + static char PgLo_export_Doc[] = + "lo_export(oid, filename) -- Export a large object to a file."; + + static PyObject *PgLo_export(PgConnection *self, PyObject *args) { + Oid oid; + char *filename = (char *)NULL; + + if (!PgConnection_check((PyObject *)self)) + return (PyObject *)NULL; + + if (!PyArg_ParseTuple(args,"is:lo_export", &oid, &filename)) + return (PyObject *)NULL; + + if (!(lo_export(PgConnection_Get(self), oid, filename))) + { + PyErr_SetString(PqErr_OperationalError, "Can't export large object."); + return (PyObject *)NULL; + } + + Py_XINCREF(Py_None); + return Py_None; + } + + /*--------------------------------------------------------------------------*/ + static char PgLo_unlink_Doc[] = "unlink() -- Removes a large object from the database."; *************** *** 992,995 **** --- 1020,1024 ---- {"lo_creat", (PyCFunction)PgLo_creat, 1, PgLo_creat_Doc}, {"lo_import", (PyCFunction)PgLo_import, 1, PgLo_import_Doc}, + {"lo_export", (PyCFunction)PgLo_export, 1, PgLo_export_Doc}, {"lo_unlink", (PyCFunction)PgLo_unlink, 1, PgLo_unlink_Doc}, {"notifies", (PyCFunction)libPQnotifies, 1, libPQnotifies_Doc}, |