Support decimal.Decimal type
See original GitHub issueDecimal types in Postgres cause a failure in db.py data type selection
I have a Django app using a MoneyField, which uses a numeric(14,0)
data type in Postgres (https://www.postgresql.org/docs/9.3/datatype-numeric.html). When attempting to export that table I get the following error:
$ db-to-sqlite --table isaweb_proposal "postgres://connection" test.db
....
column_type=COLUMN_TYPE_MAPPING[column_type],
KeyError: <class 'decimal.Decimal'>
Looking at sql_utils.db.py
at 292-ish it’s clear that there is no matching type for what I assume SQLAlchemy interprets as Python decimal.Decimal.
From the SQLite docs it looks like DECIMAL in other DBs are considered numeric.
I’m not quite sure if it’s as simple as adding a data type to that list or if there are repercussions beyond it.
Thanks for a great tool!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
decimal — Decimal fixed point and floating point arithmetic ...
The decimal module provides support for fast correctly rounded decimal floating point arithmetic. It offers several advantages over the float datatype:
Read more >8 PEP 327: Decimal Data Type
8 PEP 327: Decimal Data Type. Python has always supported floating-point (FP) numbers, based on the underlying C double type, as a data...
Read more >Decimal Data Type - Visual Basic | Microsoft Learn
The Decimal data type provides the greatest number of significant digits for a number. It supports up to 29 significant digits and can ......
Read more >Decimal data type - Wikipedia
Language support C# has a built-in data type 'decimal', consisting of 128-bit resulting in 28-29 significant digits. It has an approximate Range of...
Read more >high-precision calculations in Python with Decimal - ZetCode
The Decimal is a floating decimal point type which more precision and a smaller range than the float. It is appropriate for financial...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released in 2.9 https://sqlite-utils.readthedocs.io/en/latest/changelog.html#v2-9
I’m going to set it up so that Python
decimal.Decimal
is treated in a FLOAT column, until someone convinces me otherwise!