|06-17-2014, 08:24 PM||#1|
Join Date: Aug 2013
Device: Nexus 7
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))
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.
|06-17-2014, 09:30 PM||#2|
Join Date: Jul 2011
Device: Kobo Touch, Kobo Glo
All of mine use
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
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
|06-17-2014, 11:26 PM||#3|
creator of calibre
Join Date: Oct 2006
Location: Mumbai, India
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.
|Thread Tools||Search this Thread|
|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|