Vitalii Ponomar
Vitalii Ponomar

Reputation: 10946

SQLAlchemy: how to make primary_key not unique (PostgreSQL)?

I really need that. I've tried to define it in my model:

vs_id = Column(Integer, primary_key=True, unique=False)

But it didn't work - database schema has such row:

ALTER TABLE ONLY my_table__ ADD CONSTRAINT my_table___pkey PRIMARY KEY (vs_id);

How to solve this? Thanks in advance!

Upvotes: 0

Views: 2216

Answers (1)

lnafziger
lnafziger

Reputation: 25740

The primary key MUST be unique, in order to be able to refer to a specific record.

If you need this, add another field that isn't unique!

Upvotes: 3

Related Questions