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

Support With statement for cursor class #517

Closed
1 task done
Chaho12 opened this issue Jan 15, 2025 · 2 comments
Closed
1 task done

Support With statement for cursor class #517

Chaho12 opened this issue Jan 15, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@Chaho12
Copy link
Member

Chaho12 commented Jan 15, 2025

Describe the feature

In dbapi.py, i notice that Connection class DO have __enter__, __exit__, but Cursor class does not.

Is there a reason for why it doesn't have those classes? so that users can use with with statement?

with connection.cursor() as cursor:
    cursor.execute("SELECT * FROM table")
    results = cursor.fetchall()

Describe alternatives you've considered

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@hashhar hashhar added the enhancement New feature or request label Feb 24, 2025
@hashhar
Copy link
Member

hashhar commented Feb 24, 2025

Please add it, no specific reason why it's not there.

@hashhar
Copy link
Member

hashhar commented Feb 27, 2025

Fixed by merging #537

@hashhar hashhar closed this as completed Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants