2012-12-27 29 views
0

我使用此代碼從sqlite行獲取所有數據,但我只想檢索最後30個條目。只使用python檢索SQLITE中一行的最後一個值27

import sqlite3 
from matplotlib import pyplot 
fig = pyplot.figure() 

con = sqlite3.connect('growll.db') 
con.text_factory = str 
cur = con.cursor() 
cur.execute("select temp from GrowLLDados") 
ar=[r[0] for r in cur.fetchall()] 
+0

一個如何定義「最後」? –

回答

1

"select temp from GrowLLDados ORDER BY id DESC LIMIT 30"

其中id是一個自動遞增計數器或至少意味着數字越大越近的入口......

+0

完美!謝謝 – Aman

相關問題