Add schema introspection via OData endpoints to Opteryx SQLAlchemy#32
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
dbapi.pyto 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]dialect.pyto implementhas_table,get_table_names,get_view_names,get_schema_names, andget_columnsusing OData metadata, enabling fast and accurate schema browsing and column type mapping. [1] [2] [3] [4]Documentation Updates:
README.mdwith a new section showing how to use SQLAlchemy'sinspect()for schema introspection, with code examples and explanations of the underlying mechanism and performance characteristics. [1] [2]Other Improvements:
0.0.8to reflect the new feature set._jwt_authenticatedflag 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.