trinodb / trinodb/trino-python-client

Support for primary and foreign keys in sqlalchemy

Open
#205 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
439
Forks
206
PR merge metrics
No merged PRs in 30d

Description

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:

  1. Block setting up constraints
  2. Allow setting up constraints (but silently ignoring them from the database perspective)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SQLAlchemy Table and Column example in the issue and investigate how primary_key and ForeignKey configurations reach Trino. Determine whether constraints should be rejected or accepted and ignored, while checking the stated CRUD-query and auto-increment compatibility concerns; done means one behavior is chosen and supported consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.