FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: support request and transaction tags by olavloite · Pull Request #558 · googleapis/python-spanner-sqlalchemy · GitHub

This repository was archived by the owner on May 14, 2026. It is now read-only.

feat: support request and transaction tags - #558

Merged
olavloite merged 5 commits into
mainfrom
dbapi-tags
Feb 21, 2025
Merged

olavloite merged 5 commits into
mainfrom
dbapi-tags

Conversation

Copy link
Copy Markdown
Contributor

Do not merge: Depends on googleapis/python-spanner#1262

Fixes #525

Adds support for setting transaction tags and request tags in dbapi.
This makes these options available to frameworks that depend on
dbapi, like SQLAlchemy and Django.

Towards #525
olavloite added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Dec 17, 2024
product-auto-label Bot added the api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. label Dec 17, 2024

ahr9n commented Dec 19, 2024

Copy link
Copy Markdown

Thanks for your support!

BTW, this request_tag = self.execution_options.get("request_tag") means the request tag will be on connecting to spanner engines [so, it will be the same for all the transaction queries -- on transaction level], but it should be on executing queries [to be on query level], right?

transaction_tag = self.execution_options.get("transaction_tag") is making sense, since the whole transaction will belong to one connection.

Copy link
Copy Markdown
Contributor Author

@ahr9n

BTW, this request_tag = self.execution_options.get("request_tag") means the request tag will be on connecting to spanner engines [so, it will be the same for all the transaction queries -- on transaction level], but it should be on executing queries [to be on query level], right?

You can set execution_options on a lower level than the engine. E.g. it can also be set for specific queries like this:

with Session(engine.execution_options(read_only=True)) as session:
    # Execute two queries in a read-only transaction.
    session.scalars(
        select(Singer).execution_options(request_tag="my-tag-1")
    ).all()
    session.scalars(
        select(Singer).execution_options(request_tag="my-tag-2")
    ).all()

The request tag is then set on the cursor that is being used for the current query:

request_tag = self.execution_options.get("request_tag")
if request_tag:
    self.cursor.request_tag = request_tag

olavloite removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 20, 2025
olavloite marked this pull request as ready for review February 20, 2025 17:19
olavloite requested a review from bhatt4982 February 21, 2025 11:33

bhatt4982 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

bhatt4982 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Approved

olavloite merged commit c4496fd into main Feb 21, 2025
olavloite deleted the dbapi-tags branch February 21, 2025 12:32
parthea added release-please:force-run To run release-please and removed release-please:force-run To run release-please labels Feb 21, 2025
release-please Bot removed the release-please:force-run To run release-please label Feb 21, 2025
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Spanner Request Options Tags

4 participants


Back | FazBrowse Home | New Git URL