Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-17-2014, 08:24 PM   #1
DaltonST
Developer
DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.DaltonST shines like a glazed doughnut.
 
DaltonST's Avatar
 
Posts: 74
Karma: 8524
Join Date: Aug 2013
Device: Nexus 7 Tablet Android 4.4.2
Plugin row_factory values in sqlite3.connection

After searching this plugin forum, the sqlite3 documentation at https://docs.python.org/2/library/sq...on.row_factory, and calibre>src> , I am left with the single option of posting here to ask a simple question that is amazingly not answered in detail in the above documentation: What are the valid values for row_factory that will not return an error, especially the common "Float type is required" error.

My code at the moment is:

row_factory = sqlite3.Row
my_db = sqlite3.connect(path,row_factory,detect_types=sqli te3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)


There are a few values that failed, although sqlite.py shows them to be conceptually valid:

1. row_factory=(lambda cursor, row : list(row))
2. row_factory=None
3. row_factory=Connection

In standalone Python 2.7 using Sqlite3 on Windows 7, a simple "db = sqlite3.connect(dbpath)" works just fine. I am in need of the secret handshake that Calibre wants me to provide. Can you help?

Thank you in advance for your Calibre wisdom.
DaltonST is offline   Reply With Quote
Old 06-17-2014, 09:30 PM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 5,482
Karma: 5446898
Join Date: Jul 2011
Location: Australia
Device: Kobo Touch, Kobo Glo
All of mine use

Code:
with closing(sqlite.connect(self.device_database_path())) as connection:
    connection.text_factory = lambda x: unicode(x, "utf-8", "ignore")
    connection.row_factory = sqlite.Row
"self.device_database_path()" returns the full path to the database.

I don't use the row_factory everywhere. The code I was working with initially didn't and just used numeric indices into the results. I'm now using a mix depending on when I wrote the code and how many columns are in the result. If I have to take my shoes of to count, I use the names
davidfor is offline   Reply With Quote
 
Enthusiast
Old 06-17-2014, 11:26 PM   #3
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: 25,952
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Note that calibre does not use the python sqlite3 module, it uses apsw. And I never use row factories, they are an unnecessary performance drain.
kovidgoyal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLITE3 / COLLATE without accents aurigod Development 3 01-05-2014 05:01 AM
Where is file name in sqlite3 db? Tomladams Library Management 3 11-12-2012 02:31 PM
Connection Error every time i plugin my reader (PRS 350) stefan_80000 Devices 13 08-13-2012 05:49 AM
Firstname as author - metadata.db and SQLite3 Starson17 Calibre 11 12-20-2009 02:01 PM
Wireless internet connection frustrating IDS connection Socrates iRex 8 10-21-2009 12:46 PM


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


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