so this is what i got working wonderfully but using psycopg2 directly
instead of the DAL. AGAIN, i would love to convert this back to the DAL
for seemlessness and grace.
def getbinary():
try:
c = psycopg2.connect("dbname='tms' host='%s' user='%s'
password='%s'" % ('localhost', 'username', 'passwd'))
q = c.cursor(cursor_factory=psycopg2.extras.DictCursor)
q.execute('select png from png where (id = 1);')
data = StringIO(q.fetchone()[0])
c.commit()
finally:
if ('q' in locals()) and (q is not None):
q.close()
if ('c' in locals()) and (c is not None):
c.close()
#bos...optional until eos and here to double check the binary read via
a pure file
f = open('/opt/web-apps/web2py/applications/tms/out1.png', 'wb')
f.write(data.getvalue())
f.close()
data.seek(0)
#eos
response.headers['Content-Type'] = 'image/png'
return response.stream(data, 1024)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.