Ok, in my declarative base, I have this:

    @declared_attr
    def __mapper_args__(cls):
          return {'column_prefix': cls.__tablename__[0:5]}


That wasn't working at all, so to test it, I went into one class 
declaration and specified it directly (no inheritance) as so:

__mapper_args__ = {'column_prefix': 'ste_'}


Then I ran:

 Base.metadata.drop_all(engine)

 Base.metadata.create_all(engine) 

 
and my col-names in the DB for that table still don't have the "ste_" 
prefix.

Can anyone tell me what I'm doing wrong?

Thx
Dewey



On Thursday, December 11, 2014 2:37:27 PM UTC-6, Mariano Mara wrote:
>
>
>
> 2014-12-11 17:28 GMT-03:00 dewey <[email protected] <javascript:>>:
>>
>> Oh doh...that is perfect!!!
>>
>> Except for now, I either need to merge my __mapper_args__ from each 
>> table to my base __mapper_args__
>>
>> Or is there a way to add to __mapper_args__ in the base DYNAMICALLY 
>> based on some property in the class?
>> That would mean I could automate the whole process..
>>
>>
> You decorate your __mapper_args__ with declared_attr (see 
> http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/declarative.html#sqlalchemy.ext.declarative.declared_attr)
>  
> and build your required __mapper_args__ according to the class you are in 
> (see the second example in the docs I just linked).
>

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

Reply via email to