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

feat: allow configuring an engine context manager #30266

Merged
merged 2 commits into from
Sep 23, 2024
Merged

Conversation

betodealmeida
Copy link
Member

SUMMARY

This PR introduces a configurable context manager that wraps the create_engine call to analytical databases. The intended use case is to configure the Oracle driver with tenant-specific settings in a multi-tenant environment, but there are many other potential use cases for this:

  1. Custom logging
  2. Supressing noisy logs from 3rd party database drivers
  3. chrooting to prevent 3rd party databases drivers from accessing the filesystem (maybe using pychroot)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Added a unit test.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot bot added change:backend Requires changing the backend data:connect Namespace | Anything related to db connections / integrations labels Sep 13, 2024
# Function that computes the allowed schemas for the CSV uploads.
# Allowed schemas will be a union of schemas_allowed_for_file_upload
# db configuration and a result of this function.
def allowed_schemas_for_csv_upload( # pylint: disable=unused-argument
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote this as a function since it's easier to read and removes the lambda complaint from the linter.

@betodealmeida betodealmeida changed the title Engine context feat: allow configuring an engine context manager Sep 13, 2024
Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Did grepping to check if there were some rogue create_engine calls not going through this method and it looked squeaky cleaned.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@betodealmeida
Copy link
Member Author

Nice. Did grepping to check if there were some rogue create_engine calls not going through this method and it looked squeaky cleaned.

@mistercrunch yeah, when we implemented SSH tunneling we had to consolidate all the logic in a single place.

@betodealmeida betodealmeida merged commit 710406a into master Sep 23, 2024
34 of 35 checks passed
@rusackas rusackas deleted the engine-context branch September 23, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:backend Requires changing the backend data:connect Namespace | Anything related to db connections / integrations preset-io size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants