Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlDecimal raises RuntimeError for numbers less than or equal to 1e-5 independent of the scale specified #100

Open
dfox-rms opened this issue Feb 21, 2023 · 0 comments

Comments

@dfox-rms
Copy link

dfox-rms commented Feb 21, 2023

Hi, I am having receiving an error when converting Python floats to SqlDecimal.

Here is a minimal example:

import ctds
afloat = 1e-4
# runs successfully
result = ctds.SqlDecimal(afloat, 38, 0)

bfloat = 1e-5
# raises "RuntimeError: failed to convert '1e-05'"
try:
    result = ctds.SqlDecimal(bfloat, 38, 0)
except RuntimeError as e:
    print(e)

cfloat = 1e-5
# raises "RuntimeError: failed to convert '1e-05'"
try:
    result = ctds.SqlDecimal(cfloat, 38, 8)
except RuntimeError as e:
    print(e)

My setup:
MacOS BigSur
Version 11.7
Python 3.10.9
Working in a Conda Environment
Name Version Build Channel
ctds 1.14.0 py310h90acd4f_3 conda-forge
Result of running $ tsql -C:
Compile-time settings (established with the "configure" script)
Version: freetds v1.1.15
freetds.conf directory: /Users/.../miniconda3/envs/.../etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: auto
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: yes
GnuTLS: no
MARS: yes

Thanks for any assistance you can provide. CTDS has been a great help on previous projects, so thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant