This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sqlite3 converter not being called
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: ghaering Nosy List: erlendaasland, ghaering, kmk, ned.deily, peter.otten, r.david.murray, serhiy.storchaka
Priority: normal Keywords:

Created on 2014-02-10 21:52 by kmk, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
check_with_output.txt kmk, 2014-02-10 21:52 test code with output
check_with_output.txt kmk, 2014-02-10 23:00
demo.py peter.otten, 2014-02-11 10:06
demo2.py kmk, 2014-02-11 17:45
demo3.py peter.otten, 2014-02-11 23:46
demo2a.py kmk, 2014-02-12 15:58
workingdemo.py BreamoreBoy, 2014-07-09 07:14 Works with 3.4.1 on Windows 7
Messages (12)
msg210873 - (view) Author: Kathryn M Kowalski (kmk) Date: 2014-02-10 21:52
I have a timestamp converter that works on 2.5 but doesn't on 2.7.2 (ActiveState 2.7.2.5  Attached is some pared down test code and output from a machine running 2.5 and one running 2.7.  At one point I even put print statements in the converter - they show up under 2.5 not 2.7.  I don't think it is getting called.
msg210878 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-02-10 22:10
Can you pare it down further so that it only uses stdlib code?
msg210889 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-02-10 23:23
Hmm.  Looks like I would need a copy of your database to be able to run this?  Maybe you could add something to create the schema and add the rows to be queried?

There are tests for the converter/adapter functionality, so it must be something specific about your schema that is triggering this.
msg210917 - (view) Author: Peter Otten (peter.otten) * Date: 2014-02-11 10:06
I have condensed your code into a self-contained demo.
Unfortunately that seems to work on 2.7 (I don't have 2.5).
msg210989 - (view) Author: Kathryn M Kowalski (kmk) Date: 2014-02-11 17:45
Worked on my machine too - but if you add "union all" AND "order by" it breaks
msg211015 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-11 20:44
Use "select alpha".
msg211043 - (view) Author: Peter Otten (peter.otten) * Date: 2014-02-11 23:46
Are you sure that the converter is called in Python 2.5?
I've looked into the source (Modules/_sqlite/cursor.c), and if I understand the code correctly it uses the sqlite3_column_decltype() function from the sqlite3 API to determine the column type.

So Python would be at the mercy of the sqlite3 implementation.
msg211048 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-02-12 00:24
Perhaps the external pysqlite distribution from PyPI was installed on 2.5.  Kathryn, can you supply the output from the two versions?

import sqlite3
print(sqlite3.version)
print(sqlite3.sqlite_version)
msg211097 - (view) Author: Kathryn M Kowalski (kmk) Date: 2014-02-12 15:58
See attached file with output from both python versions.  It is using the converter as shown in demo2a.  The code using the converter was working on 2.5 for years - it quit working on the move to 2.7 because it couldn't compare a datetime to the text string returned from the database.
msg222601 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-09 07:14
Can somebody try my code on 2.7 as I don't run it anymore.  You'll probably have to undo the str => bytes dance I've just performed.  Any reason why the default convertors and adapters described here https://docs.python.org/2/library/sqlite3.html#default-adapters-and-converters can't be used?  Maybe something to do with microsecond formatting for which I know there is a completely separate issue?
msg393946 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-05-19 11:13
I'm unable to reproduce this on 3.8 though 3.11a0. It's unclear to me if this even was an issue. (I have no ancient Python versions to test with.)

Closing as out-of-date in a day or two, unless someone disagrees.
msg398992 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-08-05 10:58
Closing as out-of-date. If anyone disagrees, please reopen :)
History
Date User Action Args
2022-04-11 14:57:58adminsetgithub: 64786
2021-08-05 10:58:40erlendaaslandsetstatus: pending -> closed
resolution: out of date
messages: + msg398992

stage: resolved
2021-05-19 11:13:31erlendaaslandsetstatus: open -> pending
nosy: + erlendaasland
messages: + msg393946

2019-04-26 17:23:26BreamoreBoysetnosy: - BreamoreBoy
2015-01-11 01:59:19ghaeringsetassignee: ghaering

nosy: + ghaering
2014-07-09 07:14:27BreamoreBoysetfiles: + workingdemo.py

nosy: + BreamoreBoy
messages: + msg222601

components: + Library (Lib), - Windows
2014-02-12 15:58:14kmksetfiles: + demo2a.py

messages: + msg211097
2014-02-12 00:24:27ned.deilysetnosy: + ned.deily
messages: + msg211048
2014-02-11 23:46:27peter.ottensetfiles: + demo3.py

messages: + msg211043
2014-02-11 20:44:32serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg211015
2014-02-11 17:45:23kmksetfiles: + demo2.py

messages: + msg210989
2014-02-11 10:06:46peter.ottensetfiles: + demo.py
nosy: + peter.otten
messages: + msg210917

2014-02-10 23:23:26r.david.murraysetmessages: + msg210889
2014-02-10 23:00:19kmksetfiles: + check_with_output.txt
2014-02-10 22:10:10r.david.murraysetnosy: + r.david.murray
messages: + msg210878
2014-02-10 21:52:57kmkcreate