Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread dewey
I've added a naming convention to my metadata object (using declarative): customMetadata = MetaData(naming_convention=constraintNameConv) # schema='pay' Base = declarative_base(cls=DbBase, metadata=customMetadata, constructor=record_constructor) and now I'm getting this error when I try to

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread Michael Bayer
what kind of constraint has that problem, keep in mind there’s primary key constraints, there’s a UNIQUE constraint if you say unique=True, etc. need more info dewey de...@pathoz.com wrote: I've added a naming convention to my metadata object (using declarative): customMetadata =

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread dewey
Thanks very much for the response and I'm not sure how to answer that. Apart from my entry point: Base.metadata.create_all(engine) the stack trace only references SA code. so I don't know which constraint is causing the problem I have about 10 tables with a large mix of PKEY, FKEY, index,

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread Michael Bayer
well seeing the actual naming convention would help…. :) it looks like a CHECK constraint. dewey de...@pathoz.com wrote: Thanks very much for the response and I'm not sure how to answer that. Apart from my entry point: Base.metadata.create_all(engine) the stack trace only references SA

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread dewey
I've checked and I don't have an EXPLICIT check constraints but I understand thats not definitive. Here is the pattern: @event.listens_for(Column, before_parent_attach) def attach(target, tableObj): if tableObj.metadata is Base.metadata: target.name = %s%s % (tableObj.name[0:4],

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread Michael Bayer
dewey de...@pathoz.com wrote: I've checked and I don't have an EXPLICIT check constraints but I understand thats not definitive. OK sometimes these come out for boolean or ENUM fields. For Booleans I’d probably turn off this constraint, set create_constraint=False:

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-31 Thread dewey
Sorry...change which constraint naming pattern? I'm not tracking what the problem is so following your directions to fix it has me a bit lost. What I think you are saying is that SQL alchemy is creating a check(0,1) constraint for my boolean fields on the mysql server And that something

[sqlalchemy] automated column naming in the actual DB table

2014-12-12 Thread dewey
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.

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-12 Thread Michael Bayer
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

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-12 Thread dewey
Mike, Thanks so much for the answerI've watched a bunch of your video'sreally 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

Re: [sqlalchemy] automated column naming in the actual DB table

2014-12-12 Thread dewey
Ok, I figured it out..parent (param 2) is the table obj, not the declarative classwhich is fine btw: params for: @event.listens_for(“before_parent_attach”, Column) need to be reversed as so: @event.listens_for(Column, “before_parent_attach”) Thanks again for your help!! This tool