简体   繁体   中英

How to get total number of records in query result in SQL after slicing in python

I have 10 records:

Query Like: result = select * from employee Here I got 10 records. Then applying slicing on those records to show as per my requirement

r = result[1:3]

I showing 3 records from index 0 to 2. Here I want to count the number of records r variable contains exactly. At the end I am applying slicing as [9:12]. But it contains only 1 record at the end. So how I can get exact number of records after slicing done to my result set.

I tried with below:

count = r.count()

Then got the error like below:

AttributeError: 'long' object has no attribute 'count'

Any help help will be appreciated. Thanks

使用内置函数len

len(r)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM