working mysql based topfails site

This commit is contained in:
2010-04-07 11:25:28 -07:00
parent 095ed3c3b9
commit f95af53188
7 changed files with 5 additions and 6 deletions

View File

@@ -141,9 +141,8 @@ def GetOrInsertTree(conn, tree):
table, insert a new row and return the id."""
conn.execute("""SELECT id FROM trees WHERE name = %s""", (tree))
rows = conn.fetchone()
if len(rows) > 0:
return rows[0]
if conn.rowcount > 0:
return conn.lastrowid
# need to insert it
conn.execute("""INSERT INTO trees (name) VALUES (%s)""", (tree,))