Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. QSqlite 多线程操作导致数据库锁死
Qt 6.12 LTS is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved Chinese
2 Posts 2 Posters 2.8k 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
      • Unsolved