yes use the PrimaryKeyConstraint() construct

https://docs.sqlalchemy.org/en/13/core/constraints.html?highlight=primarykeyconstraint#sqlalchemy.schema.PrimaryKeyConstraint

here you'd want to put it in your __table_args__ and remove primary_key=True 
from each column


On Mon, Jun 1, 2020, at 6:16 PM, Jonathan Vanasco wrote:
> is it possible to force the order of primary keys?
> 
> for example in this setup...
> 
> class AcmeDnsServer2Domain(Base):
>  __tablename__ = "acme_dns_server_2_domain"
>  acme_dns_server_id = sa.Column(
>  sa.Integer, sa.ForeignKey("acme_dns_server.id"), primary_key=True
> )
>  domain_id = sa.Column(
>  sa.Integer, sa.ForeignKey("domain.id"), primary_key=True
> )
> 
> I want to influence the creation of the primary key to be 
> ["acme_dns_server_id", "domain_id"]
> 
> In several projects I've worked on, the order has been important. (it can 
> affect query planning and caching)
> 
> I thought I had seen something in the docs several years ago, but I just 
> spend a few fruitless minutes trying to find it.
> 

> --
>  SQLAlchemy - 
>  The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
>  To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
>  --- 
>  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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/6728fb39-f5d9-4c97-a8b3-7df7fd918efa%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/6728fb39-f5d9-4c97-a8b3-7df7fd918efa%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/c3a48f3a-ad38-4881-9bb8-da8006d45cf3%40www.fastmail.com.

Reply via email to