[Twisted-Python] problems w/ pyPgSQL and the Enterprise HOWTO
Justin Ryan
justin at gnubia.net
Sun Feb 23 16:52:37 MST 2003
Hiya all,
I'm playing around with the basics of Twisted.Enterprise, and am having
some trouble. I seem to have fixed it, but am unsure why the example in
the howto ( http://twistedmatrix.com/documents/howto/enterprise ) did
not work off the bat. I'm using pyPgSQL to connect to postgres. Here
goes:
The howto suggests:
<- snip ->
class AgeDatabase(adbapi.Augmentation):
def getAge(self, name):
sql = """SELECT Age FROM People WHERE name = ?"""
return self.runQuery(sql, name)
<- snip ->
Unfortunately, I get a TypeError which is only fixed by changing this
to:
<- snip ->
class AgeDatabase(adbapi.Augmentation):
def getAge(self, name):
sql = """
SELECT
"Age"
FROM
"People"
WHERE
"Name" = '%s'""" \
% name
return self.runQuery(sql)
<- snip ->
FWIW, postgres requires you to enclose mixed-case relations in
double-quotes (else it pretends they are all lowercase). I did have to
make all of the modifications in this second version to the original
query (whilst still including the ?, instead of %s) in order for the
query to be valid. I don't think that this would change anything, but I
suppose I could try it with all lowercase tables just for kicks..
Is this a problem with pyPgSQL? something else? pyPgSQL is the
_recommended_ module in the enterprise howto, so I didn't expect to run
into trouble with it..
Thanks in advance twisted.list! :)
-Justin
More information about the Twisted-Python
mailing list