Skip to content

Expose the QueryJob on the DBAPI cursor #1515

Closed
@r1b

Description

@r1b

Is your feature request related to a problem? Please describe.
I would like to store the job_id that references the job created after cursor.execute is called. Currently I do this:

job_id = dbapi_cursor._query_job.job_id

Describe the solution you'd like
I would prefer to do something like this:

# Returns the `QueryJob` created by the last `execute*()` call
job = dbapi_cursor.job()
job_id = job.job_id

Describe alternatives you've considered
It is possible to specify the job_id when calling cursor.execute, however:

  • I don't call cursor.execute in my code (see additional context below)
  • I would prefer to use the generated ID

Additional context
I interact with this library from the BigQuery SQLAlchemy dialect, so I never call DBAPI execute directly:

sqlalchemy_cursor = engine.execute(...)  # eventually calls `dbapi_cursor.execute`
dbapi_cursor = sqlalchemy_cursor.cursor
job_id = dbapi_cursor._query_job.job_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p3Desirable enhancement or fix. May not be included in next release.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