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)

Stef
  • 3,691
  • 6
  • 43
  • 58

1 Answers1

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

juicebox
  • 3
  • 3