Questions tagged [flask-sqlalchemy]

Flask-SQLALchemy is an extension for Flask that provides SQLAlchemy support. It is designed to make database manipulation through SQLAlchemy even easier and simpler. It has the same three clause BSD License as Flask.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

Difficulty with Database Connection in Python Flask - Getting 'OperationalError: unable to open database file' Error

I'm working on a Python Flask project where I'm facing challenges with establishing a database connection. I've set up my Flask application to use SQLite as the database backend. However, when ...
Soumya Swetangi's user avatar
0 votes
1 answer
24 views

How set schema for migration to flask

To migrate models to database, I use Flask-Migrate I want migrations to be performed in a different DB schema, but the problem is that Flask-Migrate does not look at other schemas before migration ...
oAsis_88's user avatar
0 votes
1 answer
24 views

InvalidRequestError: Entity namespace "album" has no property "album_name"

I am making a music streaming app using flask and flask-sqlalchemy. I created a form to upload a song along with the album name. I first checked whether the album is new to add the album first into ...
BHAVYA JAIN's user avatar
0 votes
0 answers
17 views

Error: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) attempt to write a readonly database

I am developing a Flask App that utilizes SQLAlchemy for database operations. During manual database initialization -- when running flask --app swimtracker init-db from the commandi line -- receive ...
OldZombee's user avatar
0 votes
0 answers
19 views

Flask SQL Alchemy: Object.query.all() does not show newly inserted records in @event.listens_for(Object, "after_insert")

I am using flask sqlalchemy and want to run a bunch of backend operations after new records have been added to a table. What I struggle with is that the event that registers the newly added records ...
Benjamin's user avatar
0 votes
1 answer
20 views

Flask-SQLAlchemy version3.1.x Old syntax doesnt work anymore

My installed version : 3.1.1 To execute RAW MySQL query, the following used to work before I updated to 3.1.1. I hadbeen using it for 3 years now. Documentation says it is deprecated and will be ...
amrutrajGore's user avatar
0 votes
0 answers
29 views

Pandas read_table never fails

Trying to learn a bit of python and test that the incoming binary data ( which is a file ) is tab-delimited. Whatever kind of string I turn into binary does not break the pandas read_table parser. I ...
godhar's user avatar
  • 1,191
0 votes
1 answer
46 views

sqlalchemy / flask: run a job with an additional insert/update commit after initial insert // @event.listens_for(Request, "after_insert")

I have a backend using flask / sqlalchemy that inserts records into a table ("Requests"). After the insert, I want to run additional jobs in the backend, whereby additional updates the table ...
Benjamin's user avatar
0 votes
1 answer
35 views

Any work around to query filter every ID in a list using in_() including duplicates?

I am trying to do something like this with SQLAlchemy: Cards.query.filter(Cards.id.in_(inventory_cards)).paginate(page=page, per_page=50) But the in_() operator only checks if the id is in the list ...
Altair Gonzalez's user avatar
0 votes
0 answers
17 views

Connecting flask shell

I am new to Flask. I have started small project using python==3.10, Flask==2.3.3, flask-shell==0.1.8, flask-sqlalchemy==3.1.1. My directory: ├── app │   ├── config.py │   ├── service │   │   └── db │  ...
denisiam's user avatar
0 votes
0 answers
11 views

Flask-Session not persisting across routes when using SqlAlchemySessionInterface

I am trying to create an application with Flask and React. I want to use the SqlAlchemySessionInterface because the application is using Postgres. The issue I am facing is that the session isn't ...
Ibrahim Khan's user avatar
1 vote
1 answer
39 views

How to use sqlalchemy's on_conflict_do_update.returning to return updated values?

I am trying to do an upsert statement and have the query return the updated values. On inserts, it works fine because there is no data but when there is an update, the query returns the old data that ...
user avatar
1 vote
1 answer
40 views

How do I make sqlalchemy/postgres use the GIN index in full text search

So, I have been using Postgres/sqlalchemy to do full text search for a while. No problems, but now it has started to become slow because number of items in table is starting to become high (like 600k ...
Drublic's user avatar
  • 670
0 votes
0 answers
39 views

SQLAlchemy error after upgrading to python 3.11 [duplicate]

I'm using Ubuntu 22.04 and I wanted to upgrade python from 3.10 to 3.11. However, now I'm experiencing problem with flask when trying to run my project. This is my pipfile: [scripts] start = "...
Maks's user avatar
  • 11
0 votes
1 answer
30 views

In Flask why when you try to validate the information recieved, the logic doesn't validate the form?

I hope you are good. I am having problems adding data to the database, when you as user, try and subimit a form, it sends it using method = "POST" which works fine, but when it trys to ...
add's user avatar
  • 19
0 votes
1 answer
49 views

Search on Products in Flask and Flask-SQLAlchemy

I am currently building a backend for a mobile application with Flask and Flask-SQLAlchemy. I am currently stuck in a function. I have a Products table in Postgres database created with Flask-...
Nacer's user avatar
  • 17
0 votes
0 answers
15 views

What method is the most common to serialise Flask-SQLAlchemy objects?

I went through many threads and tutorials on how to serialise Flask-SQLAlchemy objects into JSON, but all of them seem to suggest slightly different approaches/libraries. It is surprisingly difficult ...
stitch123's user avatar
  • 297
0 votes
0 answers
73 views

Question on Flask-SQLAlchemy / updating a parent Class on a Child delete

I have this issue which I do not know how to manage, other than writing the same code in different spots. What I want is that after an object is deleted, it makes a call to its parent object to update ...
gars50's user avatar
  • 1
0 votes
3 answers
72 views

Create a DB with SQLAlchemy(Flask)

I wanted to create a DB with SQLAlchemey but i keep getting stuck on the same Error and i dont know how to solve it or what i am doing wrong. My Code and my Terminal app.py from flask import Flask, ...
Alex666420666's user avatar
0 votes
0 answers
33 views

Deploying a Flask Application Without Internet Access

I created a Flask project that works on my laptop. I want to run it on another laptop without internet access. How can I run the program with all modules working properly without installing anything? ...
Amtiaz Ahmed's user avatar
0 votes
1 answer
30 views

How to create a search functionality in Flask that will be based on query parameters?

I am going through Python course for web-developers and currently dealing with Flask. Recently I have got a task from my lector to create a searhing functionality for endpoint "/events" with ...
KB_coding's user avatar
0 votes
1 answer
58 views

Why do SQLAlchemy query.all() and query.with_entities() return different data types?

Note: I'm using SQLAlchemy in Flask. The tables are ORM tables to an external database. I have two queries which query data. CustomerTable.query.all() and CustomerTable.query.with_entities(...
l30nh4rd's user avatar
0 votes
1 answer
38 views

Flask App on Azure Stops Collecing Logs after app. 30 minutes

I have built an Flask App hosted on Azure App Services. The app works well and I am capturing logs using the logging. The issue is that I can find the log file on kudu: /home/LogFiles as expected. But ...
PK Przemek's user avatar
0 votes
0 answers
25 views

SQLAlchemy Connection Error with Postgres SQL

My Flask Code: from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy app = Flask(_name_) app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:Admin123456%40@...
Saumitra Jagdale's user avatar
0 votes
0 answers
25 views

Flask app in apache environment creating duplicate log entries and escalating db conns

I have a python flask app which uses SQLAlchemy and flask-sqlalchemy. In the dev environment I use the built-in flask server connecting to a local postgres 14 db. The staging environment uses apache ...
Momus's user avatar
  • 394
0 votes
1 answer
33 views

Flask doesnt login after updated password

I trying to create a way to update users password in Flask, but for some reason unkown to me after the update the user cant login again. It says the password is incorrect, I cant see what might be ...
Kabllez's user avatar
  • 73
0 votes
1 answer
62 views

From dataclass "[x(id=1, c=1), x(id=2, c=4), x(...)...]" to Json/dict? | Serialize SQLAlchemy Result to Json / Struggling with output format

I am trying to retrieve all records in a sqlite3 database via sqlalchemy. Where I struggle is the output format, namely turning into a valid json format. There are quite a few tutorials how to do it, ...
Benjamin's user avatar
-1 votes
1 answer
76 views

Format of **kwargs in db.Model.query.filter_by()

I have a users class defined as follows: class users(db.Model): name = db.Column('name', db.String(100), primary_key=True) password = db.Column('password', db.String(100)) role = db.Column('...
Root's user avatar
  • 43
0 votes
1 answer
45 views

Binding columns with a table in SQLAlchemy

I have been trying to build up a webpage using Flask.I am currently on the login form: from flask import Flask,render_template,request from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) ...
Root's user avatar
  • 43
0 votes
0 answers
20 views

SQLAlchemy filtering a composite key table from subquery of itself

I am creating a subquery for a larger query. One table has some details while the second table is used for many-to-many relation ship joins. The second table is filtered using an inner join with ...
AKA_Tom's user avatar
  • 95
0 votes
0 answers
34 views

SQLAlchemy is not creating a table

I have been stuck on this for hours, but SQLAlchemy is creating a database.db in a folder /instance. It does not create any tables in it though, it literally creates an empty file. Thus it gives the ...
Anurag Kar's user avatar
0 votes
0 answers
24 views

Once I have a many-to-many relationship set up in my flask app, how do I create the associations without manually committing them in the shell?

I'm working on a Flask app for a game guild website. I have run into something that I've been unable to find any tutorials on. I have used Python, I have used MySQL, and I have used Flask but I have ...
joshua riddle's user avatar
0 votes
1 answer
50 views

Why won't any users be added to my database?

I am making a full stack application for a personal project. I am using SQLite, SQLAlchemy, and flask for the backend side of things. I made a model in models.py called "User", which of ...
Wanderer816's user avatar
0 votes
0 answers
14 views

'BaseQuery' object is not callable when using func count and group by in SQLAlchemy [duplicate]

I'm trying to query the SQLAlchemey model to return a count and the data row per say for the model but I'm getting this TypeError: 'BaseQuery' object is not callable My query is this products = ...
nicholas.reichel's user avatar
1 vote
1 answer
32 views

Is it ok to delete old Flask-Migrate migrations?

I have a Flask app that uses Flask-SQLAlchemy and Flask-Migrate for database management. I currently have ~60 migrations. Recently I refactored a part of my app, removing significant chunks of code in ...
DukeSilver's user avatar
0 votes
1 answer
34 views

Since I upgraded to flask 2.3 I am getting an error when I try to run the code from powershell in VSC. Does anyone know how to fix the error?

Here is what was previously working before I ran conda update conda and got flask version 2.3. >>$env:FLASK_APP="wsgi" >>$env:FLASK_ENV="development" >>flask run ...
jrgop's user avatar
  • 3
1 vote
0 answers
20 views

Trying to populate a drop-down menu form element with items from a relationship list

I am working on a simple web app for an online school. So far, the administrator can create a teacher profile and create and assign a class (lesson) that teacher is responsible for: class Teacher(db....
Filip Miljkovic's user avatar
0 votes
0 answers
21 views

Why SqlAchemy create_engine ECHO flag TRUE doesn't prevent SQL statement to get in the logs?

I am looking for a simple way to occasionally prevent SQLAlchemy to include SQL statements into the error logs (it could contain sensitive data). I have came across with ECHO flag for the ...
Gabor's user avatar
  • 372
0 votes
0 answers
44 views

sqlalchemy can't open database file

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file. I've created a database file called database.db (not that special) which automatically got put in a folder ...
Tim R's user avatar
  • 1
0 votes
1 answer
110 views

Implementing IS-A cardinality in Flask SQLAlchemy and Marshamllow schemas

Say I have a table called User which holds general information for all the users registered in the system: class User(db.Model): __tablename__ = 'User' id = db.Column(db.Integer, primary_key=...
Dimitar's user avatar
  • 1,151
-1 votes
1 answer
34 views

how to insert a list of dicts to sqlalchemy flask

I have a list of dictionaries like that: [{'cx_agent': 'samir', 'supervisor': 'karim', 'convo_link': 'test', 'date_of_conversation': '11/01/2001', 'quality_agent': ''}, {'cx_agent': 'farah', '...
Ali Mohamed's user avatar
0 votes
0 answers
20 views

How to bulk insert data using csv file in sqlalchemy (flask) [duplicate]

I used sqlalchemy database and have some columns will always needs a bulk insert I have tried pandas and many other ways but i can't get the solution thats the class model app.config['...
Ali Mohamed's user avatar
1 vote
3 answers
75 views

How to return a query using `join` from SQLAlchemy to use it as a Flask result, using Flask SQLAlchemy Session?

I have the following situation: I want to create a route that will return all rows that a column on both models (Tables) have the same values, using join function from SQLAlchemy. The method I created ...
Raul Chiarella's user avatar
0 votes
0 answers
21 views

Struggeling to send .jpg via requests library and store it correctly in database

Im building an app with pythons flask. For one function in want to send a jpg to the app. after receiving the image my app commits it to the database using sqlalchemy. for sending the image I read it ...
Elias's user avatar
  • 1
0 votes
0 answers
35 views

Flask SQLAlchemy "MySQL server has gone away"

Please help me to solving this problem, I've tried various ways but it's always an error like this sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2006, "MySQL server has gone ...
Annisa Lianda's user avatar
0 votes
1 answer
32 views

flask-admin add_view not adding models to the admin view

I have a flask application and I am trying to use flask-admin in it. I installed flask-admin and initialized it in my __init__.py file. __init__.py: from flask import Flask from flask_sqlalchemy ...
Ashutosh Chapagain's user avatar
0 votes
0 answers
14 views

When to commit db.session using Flask Sqlalchemy

I have a web app that uses Flask Sqlalchemy to modify database entries. The app has a multitude of different 'routes' which do different things. Within a given route, the code might edit a number of ...
hmcleay's user avatar
  • 41
0 votes
0 answers
15 views

Trying to categorize amount into different payment-methods and the amount generated, sql-alchemy case() on payment-method field

I want query the sum() function on amount generated through payment-method cash and upi separately. following is my cash and upi case. cash_case = db.case([(Order.payment_method == 'cash', Order....
dev-daru's user avatar
0 votes
1 answer
39 views

Using SQLAlchemy relationships while avoiding circular dependency with imports

I am having a problem using db.relationships. I noticed that to use relationships in my queries, each models that references another through a relationship has to be aware of that model (through ...
Grooth's user avatar
  • 65
0 votes
0 answers
7 views

Managing Server Load - Flask SQLAlchemy Postgres on Heroku

I have a Flask application I've built that uses Twilio and the OpenAI API to help political campaigns send text messages. The system worked fine in my earlier test with ~25 concurrent users. I tried a ...
a1j9o94's user avatar
  • 23

1
2 3 4 5
142