Re: [sqlalchemy] Making a unique key from two non-unique fields with reflected database?

2022-07-11 Thread Mike Bayer
On Sun, Jul 10, 2022, at 11:36 PM, Carl Brewer wrote: > On 11/07/2022 1:19 am, Mike Bayer wrote: > > background on mapping ORM classes to reflected tables is at > > https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#mapping-declaratively-with-reflected-tables > > > >

Re: [sqlalchemy] Making a unique key from two non-unique fields with reflected database?

2022-07-10 Thread Carl Brewer
On 11/07/2022 1:19 am, Mike Bayer wrote: background on mapping ORM classes to reflected tables is at https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#mapping-declaratively-with-reflected-tables

Re: [sqlalchemy] Making a unique key from two non-unique fields with reflected database?

2022-07-10 Thread Mike Bayer
background on mapping ORM classes to reflected tables is at https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#mapping-declaratively-with-reflected-tables and there are three general methods depending on your needs. DeferredReflection is oriented towards explicit class setup, and

[sqlalchemy] Making a unique key from two non-unique fields with reflected database?

2022-07-10 Thread Carl Brewer
I'm reflecting a table into the ORM, that has no defined unique key, but has two fields that when combined are unique - it's MySQL, but that shouldn't matter. Eg: int userID and int groupId are non-unique, but when combined they are. Can anyone point me at a simple example of how to do