Dear readers,
This is a beginner's question, but I am really stuck with this problem.
Currently I am trying to retrieve data from a given Oracle database with
Sqlalchemy (version 0.7.7). Until now, this worked fine for me. However,
now I have to read out this table
create table DISPLAYOPTIONS (
DOID integer constraint DO_PK primary key
USING INDEX (create index DO_PK_IX on DISPLAYOPTIONS(DOID) ),
OPT dispopt);
where dispopt is a custom type defined as
CREATE OR REPLACE TYPE DISPOPT AS OBJECT (
LABEL_X varchar2(50),
LABEL_Y varchar2(50),
LABEL_Z varchar2(50));
How do you define custom types in Sqlalchemy? I found in the documentation
http://docs.sqlalchemy.org/en/rel_0_9/core/types.html#creating-new-types
Is this the right starting point? Do you know some examples close to the
problem I face?
Furthermore, I found this on Stackoverflow:
How do I make compound columns with SQLAlchemy declarative?
<http://stackoverflow.com/questions/9565689/how-do-i-make-compound-columns-with-sqlalchemy-declarative>
linking to the documentation:
<http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#composite-column-types>
http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#composite-column-types
and set up:
class DISPOPT(object):
def __init__(self, LABEL_X, LABEL_Y, LABEL_Z):
self.LABEL_X = LABEL_X
self.LABEL_Y = LABEL_Y
self.LABEL_Z = LABEL_Z
def __composite_values__(self):
return self.LABEL_X, self.LABEL_Y, self.LABEL_Z
class DISPLAYOPTIONS(Base):
__tablename__ = "DISPLAYOPTIONS"
DOID = Column(Integer, primary_key = True)
OPT = composite(
DISPOPT,
Column('LABEL_X', String(50)),
Column('LABEL_Y', String(50)),
Column('LABEL_Z', String(50)) )
But still I am receiving error messages from the database.
Please note that I also have posted my question on Stackoverflow:
http://stackoverflow.com/questions/25137847/how-to-set-up-an-user-defined-type-in-sqlalchemy
I hope that this is tolerated on this mailing list.
Thank you very much in advance and best regards,
Felix
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.