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

SQLAlchemy 2.0 data type support for Oracle backend #75

Open
jkmacc-LANL opened this issue Nov 30, 2023 · 0 comments
Open

SQLAlchemy 2.0 data type support for Oracle backend #75

jkmacc-LANL opened this issue Nov 30, 2023 · 0 comments

Comments

@jkmacc-LANL
Copy link
Member

jkmacc-LANL commented Nov 30, 2023

Error thrown when trying to create a table in Oracle database using the following function (NNSA KB Core Affiliation table used as an example):

import pisces.schema.kbcore as kb

engine = sqlalchemy.create_engine(connection_string)

class Affiliation(kb.Affiliation):
    __tablename__ = 'test_affiliation'

    @classmethod
    def mk_table(cls, engine):
        """Creates SQL table stored in 'cls' in database"""
        cls.__base__.metadata.create_all(engine)

Affiliation.mk_table(engine)

Trying to create the table in the database throws the following error:

sqlalchemy.exc.ArgumentError: Oracle FLOAT types use 'binary precision', which does not convert cleanly from decimal 'precision'.  Please specify this type with a separate Oracle variant, such as Float(precision=53).with_variant(oracle.FLOAT(binary_precision=176), 'oracle'), so that the Oracle specific 'binary_precision' may be specified accurately.

Error can be resolved by manually formatting data types during column assignments, like (using time column as example):

/home/bspears/repo/pisces/pisces/kbcore.py

--> 507    time = Column(Float(precision=53).with_variant(oracle.FLOAT(binary_precision=53), 'oracle'),
    508        info={'default': -9999999999.999, 'parse': parse_float, 'dtype': 'float', 'width': 17, 'format': '17.5f'})

ping: @bspears-LANL @rad-lanl

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