数据库在ListView中显示数据时被锁定

发布于 2025-01-30 17:27:42 字数 830 浏览 5 评论 0原文

警告数据库已锁定为0:00:10.000000。确保在交易期间始终将事务对象用于数据库操作。

在屏幕上显示数据时,我收到了此错误。这花费了太长时间,所以我必须减少时间。

在FutureBuilder中,我称之为这样的方法:

future: Provider.of<AllMethodCallProvider>(context,listen: false).sendAllOfflineData(context, accessToken).
then((value) {Provider.of<StowDetailProvider>(context, listen: false).searchPOItem(accessToken:accessToken,po_id: widget.po_id!,selectedSiteId: widget.siteId!,poNumber:widget.searchPOText!,   searchVendorPartNumber:widget.vendorPartName!,vendorName:widget.vendorName!,itemStatus:widget.item_status!,
          context: context).then((value) {
        Provider.of<StowDetailProvider>(context,listen: false).isSubmitted = false;
      });
    }),

我用于-loop在列表中添加API数据。我尝试了等待batch.commit();,但没有得到预期的输出。

Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction.

I received this error while showing data in screen. And it takes too long so I have to reduce time.

In Futurebuilder I called method like this :

future: Provider.of<AllMethodCallProvider>(context,listen: false).sendAllOfflineData(context, accessToken).
then((value) {Provider.of<StowDetailProvider>(context, listen: false).searchPOItem(accessToken:accessToken,po_id: widget.po_id!,selectedSiteId: widget.siteId!,poNumber:widget.searchPOText!,   searchVendorPartNumber:widget.vendorPartName!,vendorName:widget.vendorName!,itemStatus:widget.item_status!,
          context: context).then((value) {
        Provider.of<StowDetailProvider>(context,listen: false).isSubmitted = false;
      });
    }),

I used for -loop to add API data in list. I tried await batch.commit(); but am not getting expected output.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秉烛思 2025-02-06 17:27:42

它的僵局发生在所需的数据库中。您需要检查是否需要原子。
使用交易来确保您的需求是原子。

await database.transaction((txn) async {
  // Ok
  await txn.execute('CREATE TABLE Test1 (id INTEGER PRIMARY KEY)');
  
  // DON'T  use the database object in a transaction
  // this will deadlock!
  await database.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)');
});

不仅僵局发生在所需的语法中。
也许我们中的数据库要求不合适,可能发生僵局。
检查您的所有要求不是同时的,如有必要,请使用交易以确保原子质。

Its deadlock occurred in the database required. You need to check if any require are atomic.
Use transaction to make sure your requires are atomic.

await database.transaction((txn) async {
  // Ok
  await txn.execute('CREATE TABLE Test1 (id INTEGER PRIMARY KEY)');
  
  // DON'T  use the database object in a transaction
  // this will deadlock!
  await database.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)');
});

And not only deadlock occurs in the required syntax.
maybe our of you use of the database requirements is not suitable and could occur a deadlock.
Check all of your requirements are not at the same time, if necessary use transactions to make sure are atomic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文