PostgreSQL and external method
I am trying to hook up a PostgreSQL database to Zope through an external method. Here's my method: def hello(): import sys from pg import DB conn = DB('demodb',user='skippy') x = conn.query("SELECT * from testtable") return x It works from the Python command line. But in my Zope page I get <pg query result> Also, is there a single best adapter for Postgres? I'm using PyGreSQL (the FreeBSD port) but I have heard others say it is horribly broken. I can't seem to find much in the way of documentation for installing and using the various adapters (psycopyg, PyGreSQL).
def hello(): import sys from pg import DB conn = DB('demodb',user='skippy') x = conn.query("SELECT * from testtable") return x
It works from the Python command line.
What does that mean exactly? The code just defines a function.
But in my Zope page I get <pg query result>
What is the code you use to process and print x? Groeten, Rene Pijlman
[John VanDyk]
I am trying to hook up a PostgreSQL database to Zope through an external method.
Here's my method:
def hello(): import sys from pg import DB conn = DB('demodb',user='skippy') x = conn.query("SELECT * from testtable") return x
It works from the Python command line. But in my Zope page I get
<pg query result>
It probably is working OK in Zope too. Presumably conn.query() should return a "query result", which would be some kind of structure, probably a list. It may know how to print itself, and perhaps that's what you saw when you ran it from the command line (you don't say what the result was). Probably this structure is a list of lists, or a list of dictionaries; perhaps it is a class instance. You ought to be able to find out in the documentation, or just by trying things in python. Once you know, it should be easy to iterate through it in Zope. Cheers, Tom P
participants (3)
-
John VanDyk -
Rene Pijlman -
Thomas B. Passin