我想检索我的Sqlite3数据库的第100行:
connection = sqlite3.connect('aktua.db')
cursor = connection.cursor()
print('Actual \tCliente \tHistórica')
cursor.execute("SELECT * FROM Referencias WHERE r_aktua LIKE '%K'").fetchmany(size=100)
for row in cursor:
print('%s \t%s \t%s' % row)
cursor.close()
connection.close()我的代码检索数据库的所有行(+4000)。
我读过sqlite3.Cursor.fetchmany文档和SQLite Python教程。
怎么了?
发布于 2014-03-10 12:20:16
使用此方法限制sql选择:
"SELECT * FROM Referencias WHERE r_aktua LIKE '%K' LIMIT 100"或将代码更改为:
rows = cursor.execute("SELECT * FROM Referencias WHERE r_aktua LIKE '%K'").fetchmany(size=100)
for row in rows:
print('%s \t%s \t%s' % row)https://stackoverflow.com/questions/22299793
复制相似问题