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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -