得到sqlite的数据条数的代码

https://blog.csdn.net/weixin_35754962/article/details/129060944

import sqlite3
 
conn = sqlite3.connect('example.db')
cursor = conn.cursor()
 
# 查询数据条数
cursor.execute("SELECT COUNT(*) FROM table_name")
count = cursor.fetchone()[0]
print(count)
 
conn.close()

 

posted @ 2023-10-22 20:51  liushao-AI  阅读(147)  评论(0编辑  收藏  举报