views:

524

answers:

5

I've written a Windows desktop application that works with Sqlite very nicely. It was a single user app, and the database sits right on the machine where the app runs.

However, the application has grown, and now multiple users should be able to run the app and connect to one shared database.

I'd like to just be able to share the sqlite file on a network drive, but that would obviously result in corrupted data unless someone has any ideas.

I guess I could require the install of a database server, but a commercial MySQL license doesn't make sense, PostgreSQL is different enough that I'd have to rewrite a lot of my application. I haven't worked with Firebird at all, so I'm not sure if that's a good solution or not.

Are there any Sqlite database servers that can be installed that handle the incoming transactions on the Sqlite database file?

If I require the client to download and install MySQL on their own, do I have to have a commercial license?

Any suggestions or direction would be great, thank you.

+3  A: 

What about SQL Server Express, its free and should stop you having to rewrite most of your code,

Rippo
+1  A: 

I don't know why you assume that the data file will be corrupted if you put it on a network drive and let multiple instances of your app access it at the same time. If you do mainly reading, you should be alright. If you do a lot of writes, you will probably suffer a performance hit, since only one instance can write at the same time. (See http://www.sqlite.org/faq.html)

If you do a lot of writes, you probably will need a standalone server installation - have you considered MS SQL Server Express ? Should be easy and simple to get up and running.

driis
The Sqlite forum says that if it's on an FNS file system, it won't be able to lock. Is it true that Windows shares us SMB and not NFS so there wouldn't likely be a problem? I'm concerned about having to write code around every search to loop if the file is locked.
Ben Mc
+2  A: 

You may be able to use the Sqlite file on a shared network drive as you described, depending on the underlying filesystem:

http://www.sqlite.org/faq.html#q5

Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at any moment in time, however.

SQLite uses reader/writer locks to control access to the database. (Under Win95/98/ME which lacks support for reader/writer locks, a probabilistic simulation is used instead.) But use caution: this locking mechanism might not work correctly if the database file is kept on an NFS filesystem. This is because fcntl() file locking is broken on many NFS implementations. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time. On Windows, Microsoft's documentation says that locking may not work under FAT filesystems if you are not running the Share.exe daemon. People who have a lot of experience with Windows tell me that file locking of network files is very buggy and is not dependable. If what they say is true, sharing an SQLite database between two or more Windows machines might cause unexpected problems.

James Kolpack
+3  A: 

I think that Firebird can be a very good choice

  • It's free
  • embedded version exist
Hugues Van Landeghem
I spent a good deal of time trying to get Firebird to work with my application, but ended up running into errors with every step. I had to go to FAQ's about 5 times just to see why I couldn't create a table because each time I changed something from the faq, I'd get a new error, have to go back, change something, then another error. Mostly permissions based. I don't think I want to go through these frustrations with every customer who tries to install it.
Ben Mc
I don't know your problem with permission but if you need some good GUI tools you can use www.upscene.com or www.ibexpert.com (both have free version)
Hugues Van Landeghem
+1  A: 

There are sqlite servers that make it possible to use sqlite in a multi user environment. Read here: http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork . I don't know how those solutions perform and scale.

tuinstoel