我试图获取从
python中的sqlite3数据库返回的行数,但似乎该功能不可用:
想想mysql中的php mysqli_num_rows()
虽然我设计了一种方法,但它很尴尬:假设一个类执行sql并给我结果:
# Query Execution returning a result
data = sql.sqlExec("select * from user")
# run another query for number of row checking, not very good workaround
dataCopy = sql.sqlExec("select * from user")
# Try to cast dataCopy to list and get the length, I did this because i notice as soon
# as I perform any action of the data, data becomes null
# This is not too good as someone else can perform another transaction on the database
# In the nick of time
if len(list(dataCopy)) :
for m in data :
print("Name = {}, Password = {}".format(m["username"], m["password"]));
else :
print("Query return nothing")
是否有能够在没有压力的情况下做到这一点的功能或属性.