Skip to content

Add schema introspection via OData endpoints to Opteryx SQLAlchemy#32

Merged
joocer merged 1 commit into
mainfrom
introspection
Jul 7, 2026
Merged

Add schema introspection via OData endpoints to Opteryx SQLAlchemy#32
joocer merged 1 commit into
mainfrom
introspection

Conversation

@joocer

@joocer joocer commented Jul 7, 2026

Copy link
Copy Markdown
Member

This pull request introduces comprehensive schema introspection support for the Opteryx SQLAlchemy dialect, allowing users to list schemas, tables, views, and columns (with types) via SQLAlchemy's inspection API without executing SQL queries. Introspection is powered by Opteryx's OData metadata endpoints, and results are cached for the lifetime of the connection to improve performance. The documentation is updated to reflect these new capabilities, and the implementation includes robust mapping of OData types to SQLAlchemy types.

Key changes include:

Schema Introspection Implementation:

  • Added methods to dbapi.py to fetch and cache the OData service document and metadata, providing entity and column information for introspection (get_odata_service_document, get_odata_metadata). These methods ensure authentication and handle timeouts and parsing. [1] [2]
  • Updated the dialect in dialect.py to implement has_table, get_table_names, get_view_names, get_schema_names, and get_columns using OData metadata, enabling fast and accurate schema browsing and column type mapping. [1] [2] [3] [4]
  • Introduced mapping from OData Edm types to SQLAlchemy types for accurate column typing in introspection results.

Documentation Updates:

  • Expanded the README.md with a new section showing how to use SQLAlchemy's inspect() for schema introspection, with code examples and explanations of the underlying mechanism and performance characteristics. [1] [2]
  • Updated the limitations section to clarify which introspection features are now supported and which remain unavailable.

Other Improvements:

  • Bumped package version to 0.0.8 to reflect the new feature set.
  • Minor: Added missing import in test file to support new code.
  • Internal: Set and checked a _jwt_authenticated flag to avoid unnecessary re-authentication during introspection. [1] [2]

These changes make the Opteryx SQLAlchemy dialect much more compatible with standard SQLAlchemy tooling and user workflows, especially for applications that rely on schema reflection and metadata.

@joocer joocer merged commit 40ebcda into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant