trino-python-client
trino-python-client copied to clipboard
Support for primary and foreign keys in sqlalchemy
In sqlalchemy a user can define primary keys and foreign keys as in the following example.
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
metadata_obj = MetaData()
users = Table('users', metadata_obj,
Column('id', Integer, primary_key=True),
Column('name', String),
Column('fullname', String),
)
addresses = Table('addresses', metadata_obj,
Column('id', Integer, primary_key=True),
Column('user_id', None, ForeignKey('users.id')),
Column('email_address', String, nullable=False)
)
Primary key or foreign key constraints are not (yet) supported in Trino (For example Snowflake allows to define constraints but is not actually enforcing)
sqlalchemy might depend on these configurations to generate CRUD queries (Trino also doesn't support things like auto increments so there might be other issues as well).
We can either:
- Block setting up constraints
- Allow setting up constraints (but silently ignoring them from the database perspective)
Phoenix connector already supports primary_key column property. Generally, we prefer failure to ignoring in this project (including Trino).