SQLite User Forum

Sharing a SQLite3 Database
Login

Sharing a SQLite3 Database

(1) By TLG (TLGLee) on 2022-03-04 08:50:49 [link] [source]

Hi

Does anyone have any experience or advice in sharing a SQLite database between two or more Windows machines?

Thanks

(2) By Ryan Smith (cuz) on 2022-03-04 10:08:39 in reply to 1 [source]

Yes, we have experience and advice: Don't do it!

It depends somewhat on what you wish to do.

1 - OS filesystems are reliable, networks are not.

This means that any SQLite file or multiple files will work correctly between multiple processes on the same operating system since the operating system will both respect file-locks and correctly report the locked status of a file on an OS-local device. Network file systems lie about this constantly and cannot be trusted.

2 - The main problem with not knowing or respecting the locked status of a file exists in WRITING data, reading is less sensitive to it in especially WAL mode.

So it really depends on what you want to do. Possible scenarios are:

  • Have 1 OS write the DB and others are all just consumers (readers) of data - This should work fine with WAL mode and some tweaked settings.
  • Have 1 OS create a DB file and send/push it to the other OSes that then consume the data - no problems here either.
  • Have multiple OSes both read and write to the same file - This can never work, don't do it.

If the last scenario is really what you need, there are several options out there that run on top of sqlite to provide the sort of functionality. If you wish to keep many SQLite DB files in sync all the time - BedrockDB is the best option in my opinion, or if you fancy a more client-server approach with possibly user access control, there's sqlitening, Valentina DB (and others that can be googled) or you know, Postgres or MariaDB...

(5) By Denisc on 2023-07-18 10:07:08 in reply to 2 [link] [source]

Hi,

Does your "Don't Do It" apply to a linux based Thin Client setup?

(6) By Warren Young (wyoung) on 2023-07-18 11:22:21 in reply to 5 [link] [source]

We’ll need more information than that.

There’s more than one way to do a “linux based Thin Client setup.” Describe yours.

Who does the writing?

Who does the reading?

How do these two interleave? Is it strictly read then write then read, or can operations overlap, and if so, precisely how?

What network transports are involved?

Etc, etc, etc.

In the end, testing using SQLite’s own testing frameworks and tools like my walbanger will be more useful than generic advice given in response to vague questions.

(3) By cj (sqlitening) on 2022-03-08 06:54:10 in reply to 1 [link] [source]

I have used the SQLitening server for a long time. It is rock solid.

(4) By TLG (TLGLee) on 2022-03-30 14:03:01 in reply to 3 [link] [source]

Hi,

I have been looking for tutorial information on using SQLightening, could you point me in the right direction

Thanks