Skip to content

Tag: sqlalchemy

SQLAlchemy Enum type field with integer value

There is an events model in which I want to add a memebers_count field to indicate the number of participants. The user will make a single selection from the select form. I am using Enum type for this. The model looks like this An error appears in the console when this entry is made I assumed the problem was …

Pydantic/SQLAlchemy: How to work with enums?

What is the best way to convert a sqlalchemy model to a pydantic schema (model) if it includes an enum field? Sqlalchemy Pydantic Conversion This leads to the error value is not a valid enumeration member; permitted: ‘CREATED’, ‘UPDATED’ (type=type_error.enum; enum_values=[<StateEnu…

How to add a cursor() of a db connection to a sqlalchemy.orm session? “sqlalchemy.orm.exc.UnmappedInstanceError: Class ‘builtins.int’ is not mapped”

I am in a Ubuntu 22.04 Docker container with Python 3.10. I use these apt packages: I use the following Python packages: The sessionmaker parameter autoflush is set to True. I want to add a deletion and after that an insertion to a sqlalchemy.orm session so that I commit only when the two commands worked out …

How to use googletrans’s Translator on SQLAlchemy object

I am trying to translate couple of columns in cloud MySQL table using googletrans’s Translator function. Here I read the MySQL table: And then here I try to translate it: But when I try to see if the translation took place using below code, I get no output. I am new to SQLALchemy and unable to find a so…