"TypeError: cannot pickle 'module' object" exception when using a nested sqlalchemy field #578
Unanswered
teodoryantcheff
asked this question in
Questions
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
We are using sqlmodel
0.0.8
with a pre-existing sqlite database that has a column withWe are implementing a very simple rest API fetching data from the said database.
This is the SQLModel model (stripped down to demo the issue):
Using this for the fastapi part:
Just starting results in the following, lengthy exception:
If we remove
response_model=ZIPCode
from the endpoint definitionOR
It's all good, no explosions were observed.
Also, since I prefer to have the response model for documentation purposes, for example, we tried defining a "pure" pydantic model:
and setting this as
response_model
Works as expected - no exceptions thrown, data is returned, and all.
But I don't reslly think it should be done like this,
Looked at #540, fastapi/fastapi#5514, pydantic/pydantic#380, https://stackoverflow.com/questions/70567929/how-to-use-json-columns-with-sqlmodel
Using
Makes no difference, still dies with
TypeError: cannot pickle 'module' object
Environment:
Please advice on what we are doing wrong here.
Operating System
Linux, Windows, Other
Operating System Details
No response
SQLModel Version
0.0.8
Python Version
Python 3.11.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions