Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 06-10-2014, 12:03 PM   #1
Darko
Junior Member
Darko began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2014
Device: kobo
Populating Calibre DB with NON

Hi,
I am trying to develop a tool that coverts an existing database to calibre sqlite db.
However, the sqlite driver I am using in my .Net project chokes on the word "NON".
See following table examples from calibre source:
CREATE TABLE comments ( id INTEGER PRIMARY KEY,
book INTEGER NON NULL,
text TEXT NON NULL COLLATE NOCASE,
UNIQUE(book)
);
...
CREATE TABLE data ( id INTEGER PRIMARY KEY,
book INTEGER NON NULL,
format TEXT NON NULL COLLATE NOCASE,
uncompressed_size INTEGER NON NULL,
name TEXT NON NULL,
UNIQUE(book, format)
);
...

As far as I know SQL does not have keyword "NON".
Could anybody enlighten me regarding this construct?
Tnx.
Darko is offline   Reply With Quote
Old 06-10-2014, 12:25 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
the calibre database is sqlite, NON NULL is a constraint that will cause sqlite to raise an error if you try to set a null value for a field declared as non null.
kovidgoyal is offline   Reply With Quote
Advert
Old 06-10-2014, 12:41 PM   #3
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You should use calibre to create the empty database. If you don't then it is likely that the DB version, the constraints, and the triggers won't be right.
chaley is offline   Reply With Quote
Old 06-13-2014, 08:25 PM   #4
Darko
Junior Member
Darko began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2014
Device: kobo
Thanks for answering.
I know about constrains. However based on "http://www.sqlite.org/lang_keywords.html" there is no SQLite Keyword "NON" (although NOT NULL is ok).
Probably the designers of the driver followed this table.
Darko is offline   Reply With Quote
Old 06-13-2014, 08:35 PM   #5
Darko
Junior Member
Darko began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2014
Device: kobo
Quote:
Originally Posted by chaley View Post
You should use calibre to create the empty database. If you don't then it is likely that the DB version, the constraints, and the triggers won't be right.
> You should use calibre to create the empty database.
Yes, that is exactly what I did.
However, during the testing I would like to open calibre db in VisualStudio and validate my tool with a unit test. But, as I said, sqlite driver could not get around constraint "NON" - and "NOT" works fine. Is there any difference between the two?
Darko is offline   Reply With Quote
Advert
Old 06-13-2014, 11:13 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No difference as far as I know.
kovidgoyal is offline   Reply With Quote
Old 06-14-2014, 01:39 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
For consistency, I have changed all the NON NULLs to NOT NULLs

https://github.com/kovidgoyal/calibr...fa350817a362d4
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating new reader AlexBell Library Management 3 03-15-2013 01:28 AM
Touch Script: Creating and populating shelves based on calibre tags Krytes Kobo Reader 7 10-02-2012 01:57 PM
Populating Calibre with books already on my Kobo peterbyron Kobo Reader 12 07-25-2012 03:44 AM
<dc:time> Not Populating Properly PurdueKenny ePub 3 09-22-2011 09:25 AM
<dc:date> Not Populating PurdueKenny Calibre 5 09-22-2011 09:00 AM


All times are GMT -4. The time now is 01:45 PM.


MobileRead.com is a privately owned, operated and funded community.