From: Billy G. A. <bg...@mu...> - 2003-01-13 05:18:49
|
Karsten Hilbert wrote: > Hello ! > > We are using pypgsql in the medical practice management project > GnuMed (www.gnumed.org). On task of GnuMed is to store > documents relevant to patients. We have the following code > retrieving document data from a bytea column: > > #------------------- > # start our transaction (done implicitely by defining a cursor) > cursor = aConn.cursor() > # retrieve object > cmd = "SELECT data FROM doc_obj WHERE oid='%s'" % (anObjID) > try: > cursor.execute(cmd) As a side not, not related to your problem, the previous 3 lines should be written as: cmd = "SELECT data FROM doc_obj WHERE oid=%s" try: cursor.execute(cmd, anObjID) > except: > _log.LogException("cannot SELECT doc_obj", sys.exc_info()) > return None > # cDocument.metadata->objects->file name > obj['file name'] = tempfile.mktemp() > aFile = open(obj['file name'], 'wb+') > # it would be a fatal error to see more than one result as oids are supposed > to be unique > aFile.write(str(cursor.fetchone()[0])) This will read all of data for anObjID into memory before writing it to the file. It is possible that you are running out of memory on the Win9X platform. Is there a reason you didn't use large objects instead of bytea columns? With large objects, you can read and write the data in 'chunks' to avoid consuming large quantities of memory. > aFile.close() > # close our connection > cursor.close() > #------------------- > > This works like a charm on Linux. On Win98SE, however, > we get (consistent) errors one some documents. Those docs are > large bitmaps, about 6 MB in size. > > pyPgSQL version: pypgsql-2-3.Win32.-py2.2.exe 13.12.02 > > Now, if you take a look at our log below you'll see the > following error: > > OperationalError: could not receive data from server: No buffer space availab > le (0x00002747/10055) > > Googling around a bit reveals that this error originates in > the Windows Socket API and has to do with (who'd have thunk > it) TCP transmit buffers. > Does the problem also exist on Windows NT4, 2000 or XP? This may be a Windows 98SE only problem. If it is, does Windows 98SE have to be one of the supported platforms? > > However, the only mention of a problem remotely sounding like > ours on this mailing list is here: > http://sourceforge.net/mailarchive/message.php?msg_id=1082358 > > I wonder if anyone can offer any insight, assure us it's a > known bug on the TODO list (couldn't verify that myself), or > point us to the odd registry setting we need to tweak A work-around would be to use large objects and read/write the data in chunks so as not to require such large buffers. I can, if requested, give some sample code that will illustrate the methods to use. -- ____ | Billy G. Allie | Domain....: Bil...@mu... | /| | 7436 Hartwell | MSN.......: B_G...@em... |-/-|----- | Dearborn, MI 48126| |/ |LLIE | (313) 582-1540 | |