在使用python 2.7时,是否有一种优雅的方法可以从SQLite SELECT查询中获取单个结果?
例如:
conn = sqlite3.connect('db_path.db')
cursor=conn.cursor()
cursor.execute("SELECT MAX(value) FROM table")
for row in cursor:
for elem in row:
maxVal = elem
Run Code Online (Sandbox Code Playgroud)
有没有办法避免那些嵌套的fors并直接获取值?我试过了
maxVal = cursor[0][0]
Run Code Online (Sandbox Code Playgroud)
没有任何成功.