Replies: 2 comments
-
Well, I certainly couldn't bundle in something Pydantic specific since I try to keep pyodbc as low-level as possible so it can be used in any project. So anything like this would have to be pretty generic. The syntax you have here couldn't be it since the return value from fetchall is a list and that's not something we want to change. There is a ticket or discussion requesting returning rows as dictionaries. It might be possible to design a more generic solution that allows the results to be configurable and allow you to do what you want. If you really wanted a convenient syntax for your projects using Pydantic, that works today, I
Using this is pretty transparent:
Add an override for fetchall and you are set. One thing I would think about is not actually overriding but using slightly different names like |
Beta Was this translation helpful? Give feedback.
-
We will be looking at a new backwards compatible pyodbc design where the main classes are actually written in Python and use a C library for some of there methods. If that works out, subclassing Connection and Cursor will be another option. |
Beta Was this translation helpful? Give feedback.
-
It would be cool if you could convert returned rows directly into data models like Pydantic models. Something like
Beta Was this translation helpful? Give feedback.
All reactions