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

Expose the QueryJob on the DBAPI cursor #1515

Closed
r1b opened this issue Mar 2, 2023 · 0 comments · Fixed by #1520
Closed

Expose the QueryJob on the DBAPI cursor #1515

r1b opened this issue Mar 2, 2023 · 0 comments · Fixed by #1520
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@r1b
Copy link
Contributor

r1b commented Mar 2, 2023

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
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Mar 2, 2023
@shollyman shollyman added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants