Skip to content

Python context manager raises error with datajoint connection object #1081

@drewyangdev

Description

@drewyangdev

Bug Report

Description

Datajoint connection cannot be defined with the python with, and using with is the regular way to make sure a connection is closed after dj.conn().

Reproducibility

Include:

  • OS (Linux)
  • Python Version 3.9
  • MySQL Version 8.0
  • MySQL Deployment Strategy (remote)
  • DataJoint Version 0.14.0
  • Minimum number of steps to reliably reproduce the issue
with dj.conn(**conn_info) as connection:
            print(connection)
  • Complete error stack as a result of evaluating the above steps
Traceback (most recent call last):
  File , in <module>
    app.lambda_handler(payload.EVENT, payload.CONTEXT)
  File , line 136, in lambda_handler
    with dj.conn(**conn_info):
AttributeError: __enter__

Expected Behavior

Using with to create a datajoint db connection, and close the connection at the end of the with clause.

Metadata

Metadata

Assignees

Labels

enhancementIndicates new improvements

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions