Thanks. Makes sense.
On Friday, May 29, 2015 at 10:12:07 AM UTC-5, Michael Bayer wrote:
>
>
>
> On 5/29/15 2:12 AM, r...@rosenfeld.to wrote:
>
> Thank Lucas. I've tried that as well. In all cases, SQLAlchemy always
> emits a table constraint. i.e., an additional CONSTRAINT clause in th
On 5/29/15 2:12 AM, r...@rosenfeld.to wrote:
Thank Lucas. I've tried that as well. In all cases, SQLAlchemy
always emits a table constraint. i.e., an additional CONSTRAINT
clause in the CREATE TABLE command. Maybe I've poorly phrased my
question and SQLAlchemy always emits table constra
Thank Lucas. I've tried that as well. In all cases, SQLAlchemy always
emits a table constraint. i.e., an additional CONSTRAINT clause in the
CREATE TABLE command. Maybe I've poorly phrased my question and SQLAlchemy
always emits table constraints? Here's an updated example. In all three
Unless you provide a name, the constraint will be anonymously named, so
there is no difference between that and the shortcut.
Provide a name argument to UniqueConstraint:
__table_args__ = (UniqueConstraint('alt_id', name='uq_alt_id'),)
You may also be interested in providing a naming convention
Sorry it took my a while to test this, but I didn't see any difference in
the SQL emitted. What did I miss?
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column
from sqlalchemy import Integer
from sqlalchemy import UniqueConstraint
from sqlalchemy import create_e
sure, use UniqueConstraint directly. It's better to use that than the
unique=True flag in any case.
On 5/3/15 10:29 PM, r...@rosenfeld.to wrote:
Is there a way to control whether DDL emitted by SQLAlchemy uses a
column and/or table constraint for uniqueness?
It seems the following
|
classP
Is there a way to control whether DDL emitted by SQLAlchemy uses a column
and/or table constraint for uniqueness?
It seems the following
class Part(Base):
__tablename__ = 'part'
third_party_id = Column(Integer, nullable=True, default=None, unique=
True)
emits a table constraint
CREATE