![]() |
#1 |
Deviser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
|
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. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
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 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 ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,144
Karma: 27110894
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.
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |