I tried to reflect an existing oracle database into sqlalchemy metadata:
from sqlalchemy import create_engine
from sqlalchemy import MetaData
from sqlalchemy import Table
db_uri = 'oracle://USER:PASS@MYDBTNSNAME'
engine = create_engine(db_uri)
# create a MetaData instance
metadata = MetaData()
# reflect db schema to MetaData
metadata.reflect(bind=engine)
This returns the following:
SAWarning: Did not recognize type 'BINARY_DOUBLE' of column 'column_1'(coltype, colname))
I have tried to import native types and also the types from dialect oracle using
from sqlalchemy.types import *
from sqlalchemy.dialects.oracle import *
but it seems it does not recognize BINARY_DOUBLE
type
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-13-b69d481f6a4e> in <module>()
1 from sqlalchemy.types import *
----> 2 from sqlalchemy.dialects.oracle import *
AttributeError: module 'sqlalchemy.dialects.oracle' has no attribute 'BINARY_DOUBLE'
I am using SQLAlchemy, version '1.2.1'
As described in sqlalchemy changelog, this functionality has been included in version 1.2.8:
[oracle] [bug] Added reflection capabilities for the oracle.BINARY_FLOAT, oracle.BINARY_DOUBLE datatypes
I have checked it using 1.2.18 version and now reflection works.
Have you tried overriding the default mapping relfection in your db? Like so
from sqlalchemy.dialects.oracle.base import BINARY_DOUBLE
group_table = sa.Table('groups', metadata,
sa.Column('your_column', BINARY_DOUBLE(asdecimal=True)),
autoload=True,
include_columns=[
'your_column',
'...'
],
)
Or just importing that BINARY_DOBULE
from sqlalchemy.dialects.oracle.base
I'd ask that in a comment, but I can't do so as I just joined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With