[Twisted-Python] problems w/ pyPgSQL and the Enterprise HOWTO

Justin Ryan justin at gnubia.net
Sun Feb 23 18:52:37 EST 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

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

<- snip ->

class AgeDatabase(adbapi.Augmentation):
     def getAge(self, name):
         sql = """
                 "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! :)


More information about the Twisted-Python mailing list