Python's sqlite3.register_converter() does not convert double to Decimal -



Python's sqlite3.register_converter() does not convert double to Decimal -

in sqlite3 there table:

create table t(d double)

in python, code is:

sqlite3.register_converter('double', decimal) ... d, in connection.execute('select d t limit 1'): print type(d)

the printed result is: <type 'float'> thought why?

connect database using optional argument:

detect_types=sqlite3.parse_decltypes

ie:

conn = sqlite3.connect('database.db', detect_types=sqlite3.parse_decltypes)

then go on have. should work.

see:

http://www.gossamer-threads.com/lists/python/python/627047

python sqlite3

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -