-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Somewhat confusingly, when calling connect() within a context manager, we get the Cursor but when not using a context manager, we get a Connection object. This is in contrast to behaviors with other db clients like sqlite3, SQLAlchemy, etc. and seems inconsistent. Curious to why we're not just returning self in __enter__()
Lines 27 to 35 in dd8809c
| def connect(*args, **kwargs): | |
| """ | |
| Constructor for creating a connection to the database. | |
| >>> conn = connect('localhost', 8099) | |
| >>> curs = conn.cursor() | |
| """ | |
| return Connection(*args, **kwargs) |
Lines 164 to 168 in dd8809c
| def __enter__(self): | |
| return self.cursor() | |
| def __exit__(self, *exc): | |
| self.close() |
otosky
Metadata
Metadata
Assignees
Labels
No labels