Category "sqlalchemy"

Async SqlAlchemy with FastAPI: Getting single session for all requests

I have recently migrated a REST API coded with FastApi to the new SQLAlchemy 1.4+ Async Version. My app compiles correctly and the database seems to setup just

SQLAlchemy multi column constraint

I have a number of tables in different schemas, I used the pattern from the docs. Some of my tables require multi column constraints and it was unclear what th

ForeignKey error in ormar has no attribute 'get_column_alias'

I'm testing out ormar to avoid having to create models for both api and database and ran into an issue with foreignkey assignment I can't seem to figure out. Th

How can I delete both the user and their post at the same time in my Flask App

In my head this is supposed to be easy but it's challenging me a little bit. I am trying to delete a user along with their post on a blog. However, I am not hav

Apply a filter to an automatically joined table

Here's my SQL setup create table a ( id serial primary key, ta text ); create table b ( id serial primary key,

Connecting to an Azure database using SQLAlchemy in Python

I am trying to connect to an Azure database using SQLAlchemy in Python. My code is the following: engine_azure = \ create_engine('mssql+pyodbc://{Server admin

AttributeError: module 'sqlalchemy' has no attribute 'NullType'

I am trying to configure flask SQLAlchemy with MySQLWorkBench, The following command works good: flask db migrate -m'Config' But when I try to execute flask db

SQLModel: how to load specific columns?

I tried to load specific columns from a table via the following method: from sqlalchemy.orm import load_only from sqlmodel import (Field, Session, SQLModel, cre

Does SQLAlchemy support Pervasive PSQL? connection string for it?

I googled and found this sqlalchemy-pervasive dialect. I pipped it, but I have no idea how to use it. What is connection string to pass to create_engine(.....)

SQLAlchemy: delete rows from associate table from many-to-many relationship

I noticed that when deleting one entry, the corresponding rows from the secondary table are not deleted. here my models: cashflows_tags_table = Table( "cash

SQLAlchemy update multiple rows in one transaction

How can I update multiple, existing rows in a database, using dictionary that maps existing values for one column, to the required new values for another column

SQLAlchemy: What is the best way to validate a model before inserting or updating

I'm trying to validate a SQLAlchemy model before it is inserted or updated, e.g class MyModel(db.Model): foo = db.Column(db.String(255)) bar = db.Colum

flask-sqlalchemy delete query failing with "Could not evaluate current criteria in Python"

I have a query using flask-sqlalchemy in which I want to delete all the stocks from the database where there ticker matches one in a list. This is the current q

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unknown database "mydb"

I have a problem to use flask_alchemy for my unit test function In the production environment I use a postgresql database "SQLALCHEMY_DATABASE_URI": "postgresql

How to query an array of FLOAT?

I have a table with a column with type double precision[] created like this: from sqlalchemy import Column, String, ARRAY mytablename= 'mytable' class creat

Many-to-many relationship with parent with two releationships to same child

I'm trying to model a simple (at least I thought so) relationship like in a recipe (I'm using flask-sqlalchemy): I have a Recipe, that has input materials and o

Flask_SQLAlchemy is claiming my value is not boolean?

I ran into the following error: File "/home/sandbox/.local/lib/python3.6/site-packages/sqlalchemy/sql/sqltypes.py", line 1973, in _strict_as_bool raise Ty

'\' character is getting added when executing in graphql

Not able to figure out how i can get rid of '' character. I have tried few things but it didnt work out for me. I think postgressql changes json string like tha

APScheduler RuntimeError: No application found

I have a problem. I have IP addresses and with APScheduler I try to ping them every 10 seconds and update my database. For APScheduler I understand that I need

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres when using flask to access Heroku postgres database

I've seen similar questions asked and the answer is typically to simply change "postgres" to "postgresql" in the database URL. However, I still see this error.