Mike, Thanks so much for the answer....I've watched a bunch of your video's....really good stuff.
My prefix is derived from an attribute on the model-class. Is that what parent (2nd param to your event listener) will give me? Said a different way, how do I get a ref to the class in which the column is being (has been) defined. Thanks again. Dewey On Friday, December 12, 2014 6:05:06 PM UTC-6, Michael Bayer wrote: > > > On Dec 12, 2014, at 4:12 PM, dewey <[email protected] <javascript:>> wrote: > > after re-reading the docs, it seems I misunderstood the purpose of: > > __mapper_args__ = {'column_prefix': 'ste_'} > > > that option is adding the prefix onto the Class att names, NOT onto the > actual DB column names in the table.... > > I'm looking for a way to add a global prefix onto my DB column names. > > All suggestions appreciated. > > > > assuming this is a fixed prefix that is just set up once you would either > make a function: > > from sqlalchemy import Column as _Column > > def Column(name, **kw): > newname = “myprefix_%s” % name > return _Column(newname, key=name, **kw) > > or if that is too simple, use the before_parent_attach event, which you’d > have to stick on Column: > > @event.listens_for(“before_parent_attach”, Column) > def attach(target, parent): > target.name = “myprefix_%s” % target.name > # target.key is OK here > > > -- 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.
