How to get a single result from a SQL query in python?
Or you could write a wrapper function that, given SQL, returns a scalar result:
def get_scalar_result(conn, sql): cursor=conn.cursor() cursor.execute(sql) return cursor.fetchone()[0]
I apologize for the possibly less than syntactically correct Python above, but I hope you get the idea.
If you're not using pysqlite which has the built in cursor.fetchone
cursor.execute("select value from table order by value desc limit 1")