当此 id 没有行时,您应该如何处理异常。调用代码应该如何处理这个
def function(id)
mysql_conn = MySQLdb.connect(..)
cursor = mysql_conn.cursor()
cursor.execute("""select val from fooo where id = %s""", (id))
row = cursor.fetchone()
return row[0]
当此 id 没有行时,您应该如何处理异常。调用代码应该如何处理这个
def function(id)
mysql_conn = MySQLdb.connect(..)
cursor = mysql_conn.cursor()
cursor.execute("""select val from fooo where id = %s""", (id))
row = cursor.fetchone()
return row[0]