0

Is it possible to add methods to the pyodbc Row class (with subclassing or Decorator pattern I guess, but I don't know how to implement them)

1 Answer 1

0

Apparently not, because none of the pyodbc objects have a __dict__ attribute, thus preventing any user attributes from being added/patched. Explanation here - Adding attributes to python objects

However, if your memory/performance requirements allow, you can get around this by using pypyodbc which is the pure python implementation of pyodbc. I just tested this because I wanted to subclass Connection, which works as well as dynamically adding new attributes to Row objects.

Here's another possible route to explore using ctypes - https://stackoverflow.com/a/24498525/1045885

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.