![]() |
#1 |
J
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 205
Karma: 12590
Join Date: Mar 2009
Location: Canada
Device: SONY PRS 505/300, iRex DR800SG, Nook
|
Using SQL against Calibre database
Is there someway that I can achieve the following function against the Calibre database.
Update Calibre Set COMMENT = 'new text string' concat COMMENT where publisher = 'Ramsay House' I want to bulk add some text to the COMMENT field for a specific publishers records. Thanks.......Jackie |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,324
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
This issue is discussed in the thread under this link. See in particular Kovid's answer near the end of the thread.
Good luck! ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
|
|
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
I should point out that so far, I've only used the direct SQL to do queries, not change records. There are triggers in the SQL database that will run when done the way I described, but I'm not totally certain whether those triggers will deal with all issues that need to be dealt with.
I'm in the midst of cleaning up my large database, and one of the things I expect to need to do will be similar to what you want to do. I've written enough code to know how to do it by code using Kovid's modules. I'm not at home, but I believe the modules needed are in database2.py. The way I'd do this in the code is to SQL search for the records that match the author, put the ids of those records into a list, do a loop through the list to read the metadata into a variable mi. mi.comments will be the old comments. concatenate the new text into mi.comments = mi.comments + 'New Text' then use the function in database2 that updates all the metadata for the specified index. You might want to look at the code I uploaded for the merge record function in the bug tracker. It does a lot of that type of thing, including concatenating comments from multiple records. If I was doing it now, I'd set up the development environment and just briefly add the code I need to another function, then take it out when done, although I'm sure there's a way to write a little chunk of python code, put it in a script file and execute the script from the command line. Maybe Kovid will comment. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre 7.7 cant open database | Patricia1066 | Calibre | 17 | 07-05-2010 10:23 AM |
If Calibre can't find the database... | guyanonymous | Calibre | 7 | 02-27-2010 02:48 PM |
Reference Database in Calibre? | nnxbtz | Calibre | 5 | 09-27-2009 06:16 PM |
HELP! Please Please Please! (Calibre Database Crash) | Abisha | Calibre | 7 | 06-10-2009 10:54 PM |
Possible to get tags from the calibre database? | GRiker | Calibre | 4 | 05-04-2009 02:30 PM |