@@cursor_rows变量解析

刚刚看了@@curosr_rows这个全局变量,发现这个变量挺有意思。要懂得这个变量的意义,基本上牵扯到cursor一些比较容易忽视的内容。

@@cursor_rows是用来记录当前游标的数量,也就从基础表中加载到游标中的rows

它的值有四种:

           1.  -1 动态游标,也就是无法确定个数的游标。为什么呢?

               因为这个时候的游标,只能使用 fetch next,所以并没有去统计符合查询条件的记录数。

           2.  m  加载基础表rows的个数,m为大于0的数。如果要统计这个数字,必须加上 scroll和insensitive关键字。insensitive是需要将数据从基础表转存到tempdb数据库的,二scroll因为需要定位,也对需要加载的数据进行了统计。

           3.  -m 对于 这个,需要了解游标的读取方式。如果遇到大数据量,这个数据量已经超过 sp_configure cursor threshold 的阈值。那么数据库引擎会有一个线程异步的从基础表读取数据至游标。这种情况下@@cursor_rows的值就代表了当前游标中已读取的记录数。注意:做例子的时候因为cursor threshold 选项设置为-1 ,即同步生成,所以有可能出现-1 的值,应为第一种情况。

           4 0 没有活动的游标。

 

转载于:https://www.cnblogs.com/ck0074451665/p/4301771.html

def refresh_labels(self): data4 = self.la # 连接到 SQLite 数据库文件,并创建游标对象 cursor() conn = sqlite3.connect(filepath) cursor = conn.cursor() data41 = str(self.la) if not data4.endswith('.xlsx'): data4 += '.xlsx' wo = pinjie filepath = os.path.join(wo, data4) if not os.path.exists(filepath): wb = openpyxl.Workbook() wb.save(filepath) else: wb = openpyxl.load_workbook(filepath) for i, sheet_name in enumerate(self.sheet_names): label = tk.Label(self.unique_listbox, text=sheet_name) label.grid(row=i // 3, column=i % 3, sticky="ew", padx=1, pady=1) current_time = datetime.datetime.now().time() start_time_1 = datetime.time(8, 0, 0) # 早上8点 end_time_1 = datetime.time(20, 0, 0) # 下午7点 start_time_2 = datetime.time(20, 0, 0) # 晚上8点 end_time_2 = datetime.time(7, 0, 0) # 早上7点 for i, sheet_name in enumerate(self.sheet_names): filtered_rows = [] # 优化第二段代码:检查文件是否存在 filepath = os.path.join(pinjie, self.la + '.xlsx') if os.path.exists(filepath): workbook = xl.load_workbook(filepath) sheet = workbook.active today = datetime.datetime.now().strftime('%Y/%m/%d') cell_value = sheet.cell(row=1, column=1).value if cell_value is not None and cell_value != '': for row in sheet.iter_rows(min_row=1): if row[2].value == today and row[8].value == sheet_name: datetime_obj = datetime.datetime.strptime(row[3].value, '%H:%M:%S') row_time = datetime_obj.time() if start_time_1 <= row_time <= end_time_1 and start_time_1 <= current_time <= end_time_1: filtered_rows.append(row) elif start_time_2 <= row_time or current_time <= end_time_2: filtered_rows.append(row) label = self.unique_listbox.grid_slaves(row=i // 3, column=i % 3)[0] if filtered_rows: label.config(text=f"{sheet_name} - 已點檢", fg="green") else: label.config(text=f"{sheet_name} - 未點檢", fg="red")什麽意思
最新发布
07-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值