GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DB-API should have option to use Session API (preview) in connection and/or cursor · Issue #15737 · googleapis/google-cloud-python

DB-API should have option to use Session API (preview) in connection and/or cursor #15737

New issue
Copy link
New issue
Copy link
Open
Open
DB-API should have option to use Session API (preview) in connection and/or cursor#15737
Copy link
Assignees
chalmerlowe
Labels
api: bigqueryIssues related to the BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@tswast
tswast
opened on Sep 14, 2021
Issue body actions

We'll get more details later, but https://cloud.google.com/bigquery/docs/sessions-intro recently released. This would map well to user expectations of DB-API objects, but could be considered a breaking change.

Activity

  1. tswast
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    semver: majorHint for users that this is an API breaking change.
    next major: breaking changethis is a change that we should wait to bundle into the next major version
    on Sep 14, 2021
  2. product-auto-label
    added
    api: bigqueryIssues related to the BigQuery API.
    on Sep 14, 2021
  3. tswast
    self-assigned this
    on Sep 14, 2021
  4. tswast commented on Sep 14, 2021

    @tswast
    tswast
    on Sep 14, 2021
    ContributorAuthor
    More actions

    Assigning myself for now, since this will require some design work.

  5. tswast
    changed the title [-]Breaking Change: DB-API should use Session API in connection and/or cursor[/-] [+]DB-API should have option to use Session API (preview) in connection and/or cursor[/+] on Sep 17, 2021
  6. tswast
    removed
    semver: majorHint for users that this is an API breaking change.
    next major: breaking changethis is a change that we should wait to bundle into the next major version
    on Sep 17, 2021
  7. durey commented on Jan 19, 2022

    @durey
    durey
    on Jan 19, 2022
    More actions

    Hi, just to check: there is currently no way of making use of temp tables in BigQuery (from this python library) until this is implemented, right? Are there any plans in the roadmap? I see it was even removed from the v3 to do list...

  8. tswast commented on Mar 25, 2022

    @tswast
    tswast
    on Mar 25, 2022
    ContributorAuthor
    More actions

    @durey It's possible to use temp tables by sending a single query request with multiple queries separated by semicolons. But it would be more like other systems if we were to implement this. See also the discussion on googleapis/python-bigquery#377

  9. tswast commented on Mar 25, 2022

    @tswast
    tswast
    on Mar 25, 2022
    ContributorAuthor
    More actions

    Note: I removed the "semver: major" as I think we might be able to add this as an option when creating a "connection" object.

  10. tswast
    removed their assignment
    on Apr 14, 2022
  11. chalmerlowe commented on Sep 19, 2023

    @chalmerlowe
    chalmerlowe
    on Sep 19, 2023
    Contributor
    More actions

    See the discussion on googleapis/python-bigquery#377 for context and background.

  12. r1b commented on May 14, 2024

    @r1b
    r1b
    on May 14, 2024
    Contributor
    More actions

    Checking in - is this still relevant? Its possible to pass a job_config when calling dbapi cursor execute, which could be set to create a session.

    For context, I work on a system that extends the SQLAlchemy engine in a way that allows us to control the arguments passed to dbapi cursor execute. I'm exploring porting some older multi-statement queries to use this system, possibly via sessions. Wanted to confirm that creating a session this way is directionally aligned with the interface here.

  13. tswast commented on May 15, 2024

    @tswast
    tswast
    on May 15, 2024
    ContributorAuthor
    More actions

    Custom job_config should work to get things started, but for that I think you'll want to create the session separately with a SELECT 1 query and pass in the session ID to the custom job_config.

    My thoughts for this issue would be to:

    • (Optionally) Start a new session an use that constructing a new Connection object. This would likely need to be opt-in, since Sessions come with limitations such as not allowing queries to run in parallel.
    • Integrate with BigQuery multi-statement transactions when the connection has an associated session.
    Reacted by r1b
  14. r1b commented on May 16, 2024

    @r1b
    r1b
    on May 16, 2024
    Contributor
    More actions

    Got it, thanks - couple of thoughts there:

    There is a currently a bit of an impedance mismatch when mapping SQLAlchemy Connections (which eventually invoke the corresponding DBAPI concept) onto BQ. In SQLAlchemy, these were designed to handle things like connection pooling that don't have a clear equivalent in BQ space. This connection pooling is enabled by default (in QueuePool).

    So depending on how the user's interface is configured upstream of the DBAPI, it may not be safe to assume that e.g: a connection is closed after some set of queries run. [1]

    Before SQLAlchemy v2, its also possible to use a "connectionless" execution style, which makes it unsafe to assume that a set of queries use the same connection. [2]


    It seems possible to avoid these problems with the right SQLAlchemy configuration:

    • Use NullPool, or equivalent that forces a new DBAPI connection on each SA connection [3]
    • Do not use "connectionless" execution style (deprecated in SQLAlchemy v2)

    But wanted to give a heads up that these conditions will not necessarily be true for existing users who access DBAPI via SQLAlchemy / the BigQuery SQLAlchemy dialect.

    [1] https://docs.sqlalchemy.org/en/20/core/connections.html#basic-usage
    [2] https://docs.sqlalchemy.org/en/13/core/connections.html#connectionless-execution-implicit-execution
    [3] https://docs.sqlalchemy.org/en/20/core/pooling.html#sqlalchemy.pool.NullPool

  15. parthea commented on Jan 12, 2026

    @parthea
    parthea
    on Jan 12, 2026
    Contributor
    More actions

    Transferring to google-cloud-python as the code for python-bigquery will be migrated there in 1-3 weeks.

  16. parthea
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    api: bigqueryIssues related to the BigQuery API.
    on Jan 12, 2026
  17. parthea
    transferred this issue fromgoogleapis/python-bigqueryon Jan 12, 2026
  18. parthea commented on Jan 12, 2026

    @parthea
    parthea
    on Jan 12, 2026
    Contributor
    More actions

    Transferring this issue back to python-bigquery.

  19. parthea
    transferred this issue fromgoogleapis/google-cloud-pythonon Jan 12, 2026
  20. blunderbuss-gcf
    assigned
    chalmerlowe
    on Jan 12, 2026
  21. chalmerlowe commented on Mar 2, 2026

    @chalmerlowe
    chalmerlowe
    on Mar 2, 2026
    Contributor
    More actions

    This issue was moved from the following repo as part of the monorepo migration: googleapis/python-bigquery

  22. chalmerlowe
    transferred this issue fromgoogleapis/python-bigqueryon Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @chalmerlowe
    chalmerlowe

Labels

api: bigqueryIssues related to the BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.