Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. QSqlite 多线程操作导致数据库锁死
Forum Updated to NodeBB v4.3 + New Features

QSqlite 多线程操作导致数据库锁死

Scheduled Pinned Locked Moved Unsolved Chinese
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Feng chunX
    wrote on last edited by Feng chunX
    #1

    我在子线程里通过QSqlquery写 sqlite 数据库,主线程使用其他连接通过QSqlTableModel展示数据,当数据超过300条左右时,子线程的写操作总是提示 QSqlError(“5“, “Unable to fetch row“, “database is locked“),也使用了query.finish(),和while (model->canFetchMore())
    model->fetchMore();
    model->select();
    model->query().finish();等操作,但不管用,有什么方法吗,

    JonBJ 1 Reply Last reply
    0
    • F Feng chunX

      我在子线程里通过QSqlquery写 sqlite 数据库,主线程使用其他连接通过QSqlTableModel展示数据,当数据超过300条左右时,子线程的写操作总是提示 QSqlError(“5“, “Unable to fetch row“, “database is locked“),也使用了query.finish(),和while (model->canFetchMore())
      model->fetchMore();
      model->select();
      model->query().finish();等操作,但不管用,有什么方法吗,

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Feng-chunX
      database is locked => "happens only when there is another connection with an active transaction"
      You have another process or another thread which is writing to the database?
      Google: qsqlquery "database is locked"

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved