[Zope-DB] return count() from mysql in zope
James R. Saker Jr.
jsaker at americanrelay.com
Sat Sep 4 14:58:49 EDT 2004
I'd expect this should be an easy item, but apparently am not thinking
the right way yet. I want to have a summary page in my Zope site of
values from my connected MySQL database, e.g. number of animals in the
zoo, by animalTypeID.
table: animalTypes (pkID, animalName)
and in table: animals (pkID, animalTypeID FK-->animalTypes.pkID, name,
(1,3,"Gentle Ben", "Cage #17")
(1,3,"Smokey", "Cage #44")
if I want to get a count value, e.g. the total number of Bears, my SQL
query would be:
SELECT COUNT(pkID) FROM animals WHERE animalTypeID = 3;
Within Zope, I'm not sure whether to tackle this via DTML or via a
Python script. I've tried dtml-call and that's not working, as well as a
few other approaches and clearly am missing something obvious given how
easy this should be... ideas?
More information about the Zope-DB