[newbie] MySQL : How to check if no row returned?
jane.doe at acme.com
Thu Jul 24 21:00:43 CEST 2003
(newbie, please don't flame, thank you :-))
I browsed through the archives of this site, but I didn't see how to
check if a SELECT through the MySql module returns an empty set
(whether a row exists or not, the "else" part below is always called).
Here's what I tried (using the CherryPy framework):
self.openConnection('localhost', 'root', 'test', 'mydb')
# txtClient is returned by an HTML form
myarray = myDb2.query("select * from clients where name='" +
kw['txtClient'] + "'")
# Never empty!!!
if myarray == None:
res+="<td>No client found.</td>"
Any tip much appreciated
More information about the Python-list