5

I am following the tutorial at https://docs.sqlalchemy.org/en/latest/core/tutorial.html

I see an example for primary key, it seems to use just one column

>>> users = Table('users', metadata,
...     Column('id', Integer, primary_key=True),
...     Column('name', String),
...     Column('fullname', String),
... )

how do define primary key with a sequence of columns?

2

1 Answer 1

4

try like this:

    >>> users = Table('users', metadata,
...     Column('id', Integer, primary_key=True),
...     Column('name', String, primary_key=True),
...     Column('fullname', String),
... )

use primary_key=True on any column to primary as key.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.