Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Background Database Tasks
QtWS25 Last Chance

Background Database Tasks

Scheduled Pinned Locked Moved General and Desktop
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.
  • J Offline
    J Offline
    jeremy_c
    wrote on last edited by
    #1

    I'm new to threaded applications and applications doing periodic tasks in the background (even in the same thread). I understand that the QSql classes can only be used in the thread the connection was created.

    In my application there are a few places where it syncs data from the Internet. Thus, it downloads a large amount of data from the Internet, parses that data and inserts or updates records in my database (SQLite3). I'd like for this to happen in the background, in another thread. Is there a best practice for this type of operation? Can SQLite have multiple connections open? What happens if Thread A does:

    @
    If JohnNotFound Then
    INSERT INTO abc (name) VALUES ('John')
    @

    and Thread B also does the same operation at the same time? How do you handle that, assuming there should only be one John.

    Jeremy
    http://www.kb8lfa.com

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      AFAIR sqlite blocks db for data changing operations.

      As for general answer (not only for sqlite or database, but for any threaded operations) you can use mutexes or queue with operations and execute them one a time.

      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