Skip to content
Advertisement

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 that

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=[<StateEnumDTO.CREATED: ‘CREATED’>, <StateEnumDTO.UPDATED: ‘UPDATED’>]) How can I configure either a.) the serialization with the from_orm method? or b.) the creation

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 well. The aim of

Database connection broken even with with SQLAlchemy pre-ping

Since I moved my database from a mssql docker container to an azure database as a service my web application( flask) is being disconnected after several minutes. It is simply solved by a refresh of the page but still, there is an issue here. The error raised by SQLAlchemy is an Operational Error (https://docs.sqlalchemy.org/en/14/errors.html#error-e3q8) I tried to implement the pool_pre_ping=True

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 solution. Could

Advertisement