7,053 questions
1
vote
0
answers
76
views
Memory Leak in Flask-SQLAlchemy 2.5.1 with SQLALCHEMY_RECORD_QUERIES - sqlalchemy_queries List Growing Indefinitely
Environment
Flask: 2.0.3
Flask-SQLAlchemy: 2.5.1
SQLAlchemy: 1.4.41
Deployment: Gunicorn with thread workers
Traffic: ~4 RPS in production
Observed Issue: Memory grows from 35-40% to 90% over 30 ...
1
vote
1
answer
60
views
Flask SQL model missing one positional argument
from flask import (Flask, render_template)
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://user:password@localhost/database'
db = ...
2
votes
2
answers
108
views
How to convert a datetime to period
How can I format a datetime in HTML from flask render_template so it displays how much time has passed since the datetime?
I am getting cabinet table from flask_sqlalchemy where the date is formatted ...
0
votes
1
answer
40
views
how to query a flask sqlalcheme tha has two relationship from another single table
I am trying to query a table that contains userId, which references users, and taggedNameId, which also references users and view it in my template. But i keep getting this error "int object' has ...
0
votes
1
answer
99
views
Getting AttributeError: 'tuple' object has no attribute 'items' while creating a new item in flask sql alchemy in flask admin
I have created two models in flask-sqlalchemy Product and Brand. Both have a relationship to each other. Whenever I try to create a brand I get the error AttributeError: 'tuple' object has no ...
1
vote
1
answer
101
views
I cannot create table using SQLAlchemy
I have a table with a few columns in an empty database and then db.create_all() with with app.app_context()but when I run the code, the database is still empty and there are no tables.
CODE EDITOR: ...
0
votes
0
answers
30
views
Copy an sqlite database into memory using SQLAlchemy 3.2 [duplicate]
Martyn posted this 3 years ago; how to copy an SQLite db into memory:
Stackoverflow question
# open existing db
old_db = sqlite3.connect('app.db')
# get the connection to the in memory db
conn = db....
0
votes
0
answers
101
views
sqlalchemy.exc.InterfaceError: Token is expired
sqlalchemy.exc.InterfaceError: (pyodbc.InterfaceError) ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user '<token-identified principal>'. Token ...
0
votes
1
answer
41
views
How to query child tables belonging to particular parent
Is it possible to get one/all deep-nestend child tables in one-to-many hierarchy?
Say, a user has been logged.
u = db.session.execute(db.select(U).where(U.email == '[email protected]')).scalar()
And I'...
0
votes
0
answers
56
views
Flask CRUD not working for update form, returns blank
I'm new to Flask and working through a tutorial to create a CRUD app. I can add and delete fine but when I run the update, I land on my update page but the content is not appearing.
app.config['...
0
votes
0
answers
26
views
How do I structure sqlalchemy cascade delets to remove what I want removed and leave the rest?
I am using python 3.12, the latest versions of flask, flask-sqlalchemy and sqlalchemy.
My project has a user table with an id field as in:
class User(Base):
__tablename__ = 'user'
id: Mapped[...
0
votes
0
answers
33
views
I want custom types registered in sqlalchemy to be recognized as primitive types during migration
I created a type UUIDBinary to change uuid7 from string to binary when registering and binary to string when retrieving. model looks like this.
models/common.py
from uuid6 import UUID
from sqlalchemy....
0
votes
2
answers
53
views
How to delete records that are being selected at the same time using Flask-SQLAlchemy
I'm trying to mimic this query:
DELETE FROM files WHERE id IN (SELECT id FROM files WHERE patient_id=X);
But I fail to do it using this as this only deletes a single record:
obj = File.query....
1
vote
0
answers
75
views
SQLite database not being created in Flask instance folder despite db.create_all()
I have a Flask application with SQLAlchemy that was working fine until now. Suddenly, while the instance folder is being created, the database file isn't. I tried db.create_all() via shell, it works ...
0
votes
0
answers
38
views
On the frontend the Select2 is not populating the fields for the user to select
I have an invoiceform to collect the date for postgresql database and Im having trouble with endpoints working properly and populating the drop down list for Salesman field and Product name field.
I ...
0
votes
0
answers
28
views
OperationalError: table comment has no column named data while inserting a comment into my database
I’m encountering the following error when trying to insert a comment into my SQLite database:
Error says "table comment has no column named data" apparently meaning that the data column ...
1
vote
2
answers
641
views
How to correctly use pytest with Flask and SQLAlchemy
I am trying to create a pytest suite for my Flask app. To get myself started, I followed several tutorials, notably this, this, this, and this. Now, roughly 5 hours later, I am utterly defeated by the ...
0
votes
1
answer
325
views
Why does os.getenv work with other environment variables, but cannot retrieve Mysql password variable in .env file?
Im working on my flask backend api. I have a .env file in the directory with the following variables: CLIENT_ID, CLIENT_SECRET, MYSQL_PASSWORD, FLASK_APP. I use os.getenv("CLIENT_ID") and os....
0
votes
0
answers
42
views
How to create tables in postgreSQL using Flask and flask-sqlalchemy
I'm trying to create 3 tables on my postgreSQL database using Flask. I've defined the models, configured the database to start when Flask starts and defined the URI for the connection. Apparently ...
0
votes
1
answer
187
views
How to set default datetime value with SQLAlchemy?
I'm trying to set a default server value for a created_at column in a MySQL table with the SQLAlchemy library in Python 3.13. But, whenever I start up my Flask app and the table gets created, I run ...
1
vote
1
answer
39
views
accessing sqlalchemy query filter results
I am developing my first Flask application.
In this application I have a put request from which I am querying the database. However I am not able to access and display the result of the query.
I have ...
0
votes
0
answers
51
views
How can i make this default value work, since the value is a view with data being requested from the user?
So im making an app with flask with flask.sqlalchemy, flask-forms, flask-login, within that app i have varius models, and one of those is this:
from app import db
from sqlalchemy.orm import Mapped, ...
0
votes
2
answers
414
views
I get this error - ImportError: DLL load failed while importing _psycopg: The specified module could not be found. what can I do about it?
I'm working on a Flask project with SQLAlchemy and PostgreSQL. When I try to run the Flask app, I encounter the following error:
Error: While importing 'app', an ImportError was raised:
Traceback (...
0
votes
1
answer
346
views
Generically check server database version with SQLAlchemy
I've searched all over the internet and a handful of AI bots for what seems to me to be an extremely basic function, to no avail. What is the SQLAlchemy command to check the server database version?
I ...
0
votes
0
answers
30
views
SQLAlchemy connection works but the Flask app crash
I'm writing a simple website that uses postgresql, sqlalchemy, and flask.
I have a server on which my DB is installed, and when I connect to it via this code: the connection is successful.
from ...