![]() |
#1 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jun 2018
Device: none
|
Adding books on cli leads to error
Since a few days i'm getting the following errors buy trying to add books with:
Code:
calibredb add /home/storage01/inbox/XXX.epub --library-path /home/storage01/calibre/my_bib/ Code:
Traceback (most recent call last): File "site.py", line 77, in main File "site-packages/calibre/db/cli/main.py", line 255, in main File "site-packages/calibre/db/cli/main.py", line 55, in run_cmd File "site-packages/calibre/db/cli/cmd_add.py", line 374, in main File "site-packages/calibre/db/cli/cmd_add.py", line 152, in do_add File "site-packages/calibre/db/cli/main.py", line 192, in run File "site-packages/calibre/db/cli/cmd_add.py", line 65, in implementation File "site-packages/calibre/db/cli/cmd_add.py", line 44, in book File "site-packages/calibre/db/cache.py", line 1596, in add_books File "site-packages/calibre/db/cache.py", line 63, in call_func_with_lock File "site-packages/calibre/db/cache.py", line 1566, in create_book_entry File "site-packages/calibre/db/cache.py", line 1284, in set_metadata File "site-packages/calibre/db/cache.py", line 1271, in set_field File "site-packages/calibre/db/cache.py", line 1092, in set_field File "site-packages/calibre/db/write.py", line 544, in set_books File "site-packages/calibre/db/write.py", line 466, in many_many File "site-packages/calibre/db/backend.py", line 857, in executemany File "src/cursor.c", line 236, in resetcursor ConstraintError: ConstraintError: Foreign key violation: authors is still referenced I'm running calibre 3.21 headless on Ubuntu 16.04.4 LTS. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,157
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That error indicates your database is damaged. You can use the
calibredb restore_database command. But read the help of that command first. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jun 2018
Device: none
|
Thank's for the quick reply.
Restoration is running now. Any indications why the db got corrupted? Hints coud help to avoid. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,157
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There's no way to know, the typical causes are filesystem corruption caused by using the library on a flaky filesystem such as a networked filesystem, or a flash media or ina location where multiple programs try to write tothe same folders at the same time.
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jun 2018
Device: none
|
Well, since I run calibre on a vpn that is just managing this library I guess at least the fs part might be save.
Btw. after restoring the db, the error still exists. Any other ideas? What I found out is, that the title is added to db but with no files. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,157
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Then attach your metadata.db and the book you are trying to add and I will take a look.
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,157
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Are you sure you rebuilt it, because that database is still damaged. For example,
Code:
echo 'select * from books_authors_link where author=29638;' | sqlite3 metadata.db * Error: near line 1: database disk image is malformed |
![]() |
![]() |
![]() |
#9 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,157
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can probably fix it with
Code:
echo .dump | sqlite3 metadata.db > metadata.sql sqlite3 fixed.db < metadata.sql mv fixed.db metadata.db |
![]() |
![]() |
![]() |
#10 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jun 2018
Device: none
|
In the 2nd step I'm getting the following error
Code:
Error: near line 534046: UNIQUE constraint failed: tags.name |
![]() |
![]() |
![]() |
#11 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,157
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That's ok, the db will stil be rebuilt.
|
![]() |
![]() |
![]() |
#12 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jun 2018
Device: none
|
Awesome. That works. Thank you
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error adding books | spynumber | Library Management | 6 | 02-21-2017 07:59 PM |
Adding books Error | tdwish | Conversion | 4 | 01-22-2012 06:37 AM |
error adding books | Beau | Calibre | 5 | 11-02-2010 12:03 PM |
Error adding books | Gfinch | Calibre | 2 | 08-03-2008 08:36 PM |