question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support decimal.Decimal type

See original GitHub issue

Decimal 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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, May 11, 2020
0reactions
simonwcommented, May 10, 2020

I’m going to set it up so that Python decimal.Decimal is treated in a FLOAT column, until someone convinces me otherwise!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found