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

Open
1 task done
Chaho12 opened this issue Jan 15, 2025 · 0 comments
Open
1 task done

Support With statement for cursor class #517

Chaho12 opened this issue Jan 15, 2025 · 0 comments

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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant