Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlalchemy inspect constraints support #866

Open
arkeodev opened this issue May 25, 2023 · 2 comments
Open

sqlalchemy inspect constraints support #866

arkeodev opened this issue May 25, 2023 · 2 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery-sqlalchemy API.

Comments

@arkeodev
Copy link

arkeodev commented May 25, 2023

Upon scrutinizing the schema reflection for Big Query, I am able to discern the dataset lists and glean information about the columns to a certain extent. Although it's not a mandatory requirement, I have the capability to establish primary and foreign keys on tables. However, when I attempt to retrieve this information using an inspector, the following code doesn't yield the expected results:

from sqlalchemy import inspect, create_engine
engine = create_engine('...')
inspector = inspect(engine)
primary_key = inspector.get_pk_constraint("table_name")  # returns empty
foreign_keys = inspector.get_foreign_keys("table_name")  # returns empty

Given this situation, I am wondering if there's an alternative method to extract this data without having to resort to SQL Queries on INFORMATION_SCHEMA?

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-sqlalchemy API. label May 25, 2023
@richard-sparq
Copy link

richard-sparq commented Jul 14, 2023

Clearly these methods get_pk_constraint() and get_foreign_keys() aren't implemented in bigquery-sqlalchemy (even though it is possible now to define foreign & primary key constraints in BQ). Just wondering @arkeodev if you have any further insights/workarounds to obtain these constraints?

@bush-david
Copy link

Will there eventually be support for unenforced BQ primary and foreign key constrains in bigquery-sqlalchemy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-sqlalchemy API.
Projects
None yet
Development

No branches or pull requests

4 participants