Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4248452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:15:30+00:00 2026-05-21T04:15:30+00:00

I am completely new to SQLite and I intend to use it in a

  • 0

I am completely new to SQLite and I intend to use it in a M2M / client-server environment where a database is generated on the server, sent to the client as a file and used on the client for data lookup.

The question is: can I replace the whole database file while the client is using it at the same time?

The question may sound silly but the client is a Linux thin client and to replace the database file a temporary file would be renamed to the final file name. In Linux, a program which has still open the older version of the file will still access the older data since the old file is preserved by the OS until all file handles have been closed. Only new open()s will access the new version of the file.

So, in short:

  • client randomly accesses the SQLite database
  • a new version of the database is received from the server and written to a temporary file
  • the temporary file is renamed to the SQLite database file

I know it is a very specific question, but maybe someone can tell me if this would be a problem for SQLite or if there are similar methods to replace a database while the client is running. I do not want to send a bunch of SQL statements from the server to the client to update the database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:15:31+00:00Added an answer on May 21, 2026 at 4:15 am

    No, you cannot just replace an open SQLite3 DB file. SQLite will keep using the same file descriptor (or handle in Windows-speak), unless you close and re-open your database. More specifically:

    • Deleting and replacing an open file is either useless (Linux) or impossible (Windows). SQLite will never get to see the contents of the new file at all.

    • Overwriting an SQLite3 DB file is a recipe for data corruption. From the SQLite3 documentation:

      Likewise, if a rogue process opens a
      database file or journal and writes
      malformed data into the middle of it,
      then the database will become corrupt.

      Arbitrarily overwriting the contents of the DB file can cause a whole pile of issues:

      • If you are very lucky it will just cause DB errors, forcing you to reopen the database anyway.
      • Depending on how you use the data, your application might just crash and burn.
      • Your application may try to apply an existing journal on the new file. Sounds painful? It is!
      • If you are really unlucky, the user will just get back invalid results from any queries.

    The best way to deal with this would be a proper client-server implementation where the client DB file is updated from data coming from the server. In the long run that would allow for far more flexibility, while also reducing the bandwidth requirements by sending updates, rather than the whole file.

    If that is not possible, you should update the client DB file in three discrete steps:

    • Send a message to the client application to close the DB. This allows the application to commit any changes, remove any journal files and clean-up its internal state.
    • Replace/Overwrite the file.
    • Send a message to the client application to re-open the DB. You would have to setup all prepared statements again, though.

    If you do not want to close the DB file for some reason, then you should have your application – or even a separate process – update the original DB file using the new file as input. The SQLite3 backup API might be of interest to you in that case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am completely new to LINQ in C#/.NET. I understand that I could use
I am completely new to ruby and I inherited a ruby system for a
I'm completely new to AIR but what I'm trying to do feels like it
I'm completely new at C# and NUnit. In Boost.Test there is a family of
I'm completely new to Flex and am just having a play with a sample
I'm completely new to LaTeX and something I'm wanting to do is eluding me.
I am completely new to Flex. Can I realistically develop, say, a medium complex
I'm completely new to Actionscript and I'm trying to figure out if it's possible
I know something about Java but completely new to Enterprise Java. I'm trying my
I'm writing a custom swing component (something completely new, but think JTree or JList).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.