View Single Post
Old 02-09-2013, 01:53 PM   #5
Junior Member
mwaterbu began at the beginning.
Posts: 4
Karma: 10
Join Date: Jan 2012
Device: Kindle Keyboard 3G
Originally Posted by murkyl View Post
So there is a workaround fortunately! Calibre has the capability to have the metadata database in a different directory from the library itself. You need to set it with the full path including the name of the database file in an environment variable named:
e.g. C:\Some\Path\metadata.db
This is documented here:

This link here in the forums also helped:

It turns out there is some incompatibility between SQLite and Samba. You can find a ton of posts about this if you search on 'sqlite cifs'. It looks like it is a form of file locking which is causing the problem. A full Microsoft client and server do no seem to have this problem. It seems to only occur if either the client or server is running Samba.

I've used the environment variable to move the DB and now the Calibre server updates properly when new books are added. The last step is to backup the metadata DB files now that they are no longer on the NAS.

Hope this helps someone else in the future.
Hi, I am having trouble making this work (having my library hosted on a NAS), and am hoping you can assist me. Calibre is installed to my machine (C:\Program Files\Calibre2), and my eBook files (organized by Calibre in directories with metadata.opf files and cover.jpg files) are stored on a NAS mapped to the N:\ drive.
I edited the calibre-portable.bat file to set the ebook location as follows:
IF EXIST N:\eBooks (
And I set my metadata database location as follows:
IF EXIST "C:\Documents and Settings\Administrator\Calibre Library\metadata.db" (
	IF NOT "%CALIBRE_LIBRARY_DIRECTORY%" == "C:\Documents and Settings\Administrator\Calibre Library" (
		SET CALIBRE_OVERRIDE_DATABASE_PATH="C:\Documents and Settings\Administrator\Calibre Library\metadata.db"
		ECHO DATABASE:           C:\Documents and Settings\Administrator\Calibre Library\metadata.db
		ECHO '
		ECHO ***CAUTION*** Library Switching will be disabled 
		ECHO '
so I have copied my metadata.db file from N:\eBooks (where it normally was) to C:\Documents and Settings\Administrator\Calibre Library.
However, when I launch the calibre-portable.bat file, I get the following error:
calibre, version 0.9.17
Corrupted database: The library database at N:\eBooks appears to be corrupted. Do you want calibre to try and rebuild it automatically? The rebuild may not be completely successful. If you say No, a new empty calibre library will be created.

Traceback (most recent call last):
  File "site-packages\calibre\gui2\", line 228, in initialize_db
  File "site-packages\calibre\library\", line 166, in __init__
  File "site-packages\calibre\library\", line 114, in connect
  File "site-packages\calibre\library\", line 366, in connect
DatabaseException: unable to open database file
	RemoteTraceback (most recent call last):
	  File "site-packages\calibre\library\", line 248, in run
	  File "site-packages\calibre\library\", line 225, in connect
	OperationalError: unable to open database file
Trying to rebuild the library fails, so that will not work, unfortunately. I can confirm that my library is ok though, since I can launch Calibre normally with the metadata.db file that is on the NAS at N:\eBooks (but this takes a very long time, which is why I want to use the local copy of metadata.db).
Am I missing a step?
Thanks for the help!
mwaterbu is offline   Reply With Quote