> On Dec 12, 2014, at 4:12 PM, dewey <de...@pathoz.com> 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to