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
0answers
4 views

Having error at db.session.add when I tried to execute function using apscheduler

I implemented API in Flask and working correctly. (Get some data from other API endpoint and store into database) I also want to call this API as a cron job. Thus, I am using apscheduler to execute ...
0
votes
1answer
17 views

Getting specific input from a form used multiple times on one page

I'm trying to create a cart system using flask sql-alchemy. So far I've got three models although a lot of the data in these methods is useless. class User(db.Model, UserMixin): id = db.Column(db....
0
votes
0answers
12 views

SQLAlchemy find only parents that contain specific children

I have the following many-to-many models: class Association(db.Model): parent_id = db.Column(db.Integer, db.ForeignKey( 'parent.id'), primary_key=True) child_id = db.Column(db.Integer,...
0
votes
0answers
6 views

Setting a default value of a QuerySelectField in a Flask WTForm

I have a Flask WTForm with a QuerySelectField, and would like to set the default value from the database. In the database I have a table for Jobs, and each job has a Status. class Job(db.Model): ...
0
votes
0answers
14 views

Flask SQLAlchemy Association Table: error creating backref

I have a Artist model, and a Venue model, and they have a many-to-many relationship facilitated by the Show model (the shows indicate the artist, venue and date of the concert). class Venue(db.Model):...
1
vote
0answers
29 views

SQLAlchemy - how to slice arrays to get the full range? [:] is compiled to [NULL:NULL]

I'm stuck at a specific problem with SQLAlchemy. Basically, I have a table with a column that is a nested array ({{filename1, file_url1}, {filename2, file_url2}}). I've managed to write a filter ...
0
votes
0answers
17 views

Flask-SQLAlchemy won't connect to remote server

I'm trying to use the Flask-SQLAlchemy and Flask-Migrate libraries to connect to a MySQL server, but the app keeps trying to connect to localhost instead of the remote server no matter what I put in ...
0
votes
0answers
13 views

Conditional statements in a Flask model

I have three user types which I intend to store in three different database tables. The structure is as follows: A master table that contains columns id, teacher_userid, student_userid, parent_userid,...
0
votes
0answers
28 views

Cannot Log In user using Flask

Using Python, Flask and SQLAlchemy to create a web site with a possibility to Sign Up, Log In, Log Out. The Sign Up works good and I can create a new user but the doesn't perform the action ...
0
votes
0answers
12 views

Getting sqlalchemy.exc.OperationalError while trying to connect to MySQL database using Flask-SQLAlchemy

I am trying to connect to a MySQL database using PyMySQL driver and Flask-SQLAlchemy. However, I am getting the following error. sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1045, ...
0
votes
0answers
23 views

Logging data from multiple WTForms in an sqlite3 database in Flask-Sqlalchemy

OK, please help. I'm pulling out my hair even though I know the answer HAS to be something simple. I have two forms in my Flask-SQLAlchemy web interface project: Post and Survey. Post was the first ...
0
votes
0answers
17 views

Return Child Model in Single Inheritance Table

I have Single Inheritance Table in SqlAlchemy and i wanna filter by id in parent table interface, have some way to return all child attributes using parent Model, this is my example: class ...
0
votes
0answers
20 views

SQL Alchemy query json with case insensitive operator

Table Person, column data (JSONB) example json value in data column { "name": "test", "groups": ["A", "B", "c"] } Query toCompare = "a" db_session.query(PersonEntity).filter( PersonEntity....
-1
votes
0answers
27 views

How can I have Many to Many relationship of multiple attributes from the same model with the other one in flask sqlalchemy?

I just started learning flask with this project where I'm trying to build an Inventory Management System. So here are my Entity Types and Entites: 1. Product (product_id) 2. Location (location_id) 3....
0
votes
0answers
13 views

for loop in Routes to retrieve or send data from DB (Flask-wtforms)

I am building a Dungeon & Dragon character sheet using Flask and its modules (Flask-wtform, flask-sqlalchemy). If you played D&D before, you know that the character sheet is quite complicated. ...
0
votes
0answers
20 views

How do I reliably insert/update a large number of ORM models using SQLAlchemy?

My app uses Flask-SQLAlchemy and Celery for background task processing. One common background task is hierarchical location data (stored as a set of data+closure tables) imports using a spreadsheet. I'...
-1
votes
0answers
26 views

I want an sqlalchemyquery to get testcase count for each testset in HP ALM

I want an sqlalchemy query in python to get testcase count for each testset in HP ALM and display the count for Failed, Passed and No Run testcases for each Testset. I have used python for the entire ...
0
votes
0answers
5 views

Unwanted sqlalchemy table write

I use flask-sqlalchemy for my projects in scoped sessions mode. I have a strange situation, that I cannot understand: SA wants to write changes made to a model even if that changes were not added to ...
0
votes
1answer
25 views

How can I establish a database relationship that allows different types of users to register in SqlAlchemy

I have different users that will access different funcionality in the plataform and have different information associated with them. I implemented the tables according to the diagram bellow, where I ...
0
votes
0answers
33 views

Python ORM's: best practices

We often have performance issues with our ORM in Python (Fask-SQLAlchemy). Solutions to common performance issues are well documented (see this SQLAlchemy doc for example), but actions where you read, ...
1
vote
0answers
15 views

Sorting a property in flask-admin list view

I have a model with a date of birth field, I have used the python decorator @property to make an age field, I would like to be able to sort by age on the flask-admin list view but I got the following ...
0
votes
2answers
56 views

Python Flask SQLAlchemy: "Can't determine relationship direction… for nested relationship

I'm trying to build a double-dynamic form-page where both form-items and select-options (in the drop down menus) are read from a database depending on the chosen organisation and the language ...
-2
votes
1answer
28 views

Flask restful json formating [duplicate]

I have a table is Database similar to below data. I am trying to create a REST API using Flask-Restful. I am using flask-restful and flask-sqlalchemy with the below api. /project/1 @...
0
votes
1answer
19 views

Marshmallow ModelSchema to Mapping Class Inheritance SqlAlchemy

i am with this problem, i using ModelSchema to validade my API input and this give me a Database Model, it works fine, but if i use a Mapping Class Inheritance(Single Table type) the ModelSchema give ...
-1
votes
0answers
17 views

Error :from sqlalchemy import event, inspect, orm ImportError: cannot import name 'event'

When i try to work on flask_sqlachemy to create a data base I am getting this error. I am inside my virtual environment. I have Flask_sqlalchemy version 2.4.1 I have sqlalchemy version 1.3.12 This ...
0
votes
0answers
10 views

How to have default emails available to all while having One-to-many relationship custom emails for users with sqlalchemy and flask

I had 2 tables Users and Emails. I have successfully implemented the one-to-many relationship where Users are able to create custom emails and have them retrieve and display only their own emails that ...
0
votes
0answers
24 views

When to use session when querying in Flask-SQLAlchemy?

I stumbled accross 2 ways of querying a model when trying to work with SQLAlchemy and Flask. One is with db.session and the other is directly with the model name. Is there a difference between the 2 ? ...
0
votes
0answers
22 views

Insert using only parent interface

I have a inheritance table sqlalchemy, and receive a json with a attributes from this table, but have some attributes that belong of a child and others attributes to others child, my doubt is I can ...
0
votes
0answers
23 views

Flask SQLAlchemy: (psycopg2.errors.AdminShutdown) terminating connection due to administrator command

I have a pretty standard setup of flask, SQLAlchemy and an AWS RDS with Postgresql DB. After changing RDS SSL certificates on a running system the application (flask) displayed the following ...
0
votes
1answer
29 views

Posting Nested models SQLAlchemy-Marshmallow

I am trying to wrap my head around SQLAlchemy in combination with Marshmallow. I had a Flask API that contains some Assets and Trading Pairs. I want bidirectional One-to-Many relationships between ...
0
votes
1answer
16 views

Why is my API note returning all items from the model?

I'm trying to return all items from the User model when a certain API endpoint is navigated to. Here is my Flask route: @app.route('/user/all', methods=['GET']) def get_all_users(): users = User....
0
votes
1answer
20 views

Flask SQLAlchemy self-referential ordering list

I am trying to make a self-referential tree with ordered children, but I can't seem to get it right. This is what gets me the closest, but the behavior is very unexpected. I am wondering what I am ...
0
votes
1answer
18 views

Why do I keep getting a sqlalchemy timeout using flask-login in my flask app?

I am running a Flask web application in a Docker swarm that utilizes Flask-Login for user authentication. I have a User class modeled, and I use Flask-SQLAlchemy to connect the app to a Postgres ...
0
votes
1answer
26 views

Access app_context from another task in Quart

My Quart app is created with a create_app factory method. I also have a third party library incorporated as an additional task via the create_task method. I pass a callback function to this library ...
0
votes
1answer
20 views

How to filter and display flask sqlalchemy one to many relationship data with jinja

I have two mysql tables ("song_info" and "djartist1") which they have one to many relationship. I want to display the all songs from a single artist (all posts from a specific user). But I'm getting a ...
0
votes
0answers
19 views

Getting a migrate error when I try to run flask db init on windows

When I try to run flask db init I get the following error. Note that my environment variable is activated and I already set FLASK_APP=adoption_site.py which is the script I'm trying to run. Traceback ...
-1
votes
0answers
15 views

flask-sqlalchemy query for NULL type error

I ran into unexpected behavior when trying to select all rows in a table where one specific column is NULL. Using either of these: SpaceObj.query.filter(SpaceObj.company_id.is_(None)).limit(20).all() ...
0
votes
0answers
22 views

SQLAlchemy Many-Many with condition on one table

In a Flask application, I have tables class Event(db.Model): __tablename__ = 'event' id = db.Column(db.Integer, primary_key=True, autoincrement=True) event_name = db.Column(db.String(...
0
votes
0answers
46 views

flask request url not found on the server “Error: 404 not found”?

I'm working on flask application. The route localhost:5000/user/login is not found. All other routes are working perfectly but I don't know what's going wrong with this route! Would you help me to fix ...
2
votes
0answers
64 views

import data from source db to target db using flask sqlalchemy

I want to fetch data from one source database and insert it into my targeted database using flask SQL alchemy Database_connection app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:[email protected]
0
votes
0answers
23 views

python flask csv upload to mysql if exists update else insert not working on update rows

I have a flask view function to upload and insert selected columns into a mysql database, the code works great for new entries but I need to be able to also update existing rows, I am stuck in how to ...
0
votes
0answers
14 views

Edit view in models views of flask app builder

I have been trying to use a SQL panadas query to call for the database in the edit view of the FLASK app builder. While this works, when I call for a table that is not part of the particular model ...
0
votes
1answer
43 views

Pass parameters to a decorator Class in Python

I'm trying to write a decorator for a Db Model, to makes this Model serializable def Schema(cls): class Schema(marshmallow.ModelSchema): class Meta: model = cls cls....
0
votes
1answer
21 views

search data based on date in sqlalchemy

i have a column(scheduledStartDateTime) in database which is of type datetime and i have to search previous row of data based on user entered datetime . my query is like this: order = self....
0
votes
0answers
16 views

sqlalchemy filter by different number of parameters

Is it posible to rewrite this condition to one line? def get_last_user_log(telegram_id, state=False): user_id = get_user_id(telegram_id=telegram_id) if state: log = UserLog.query....
0
votes
0answers
15 views

Code to create DB with Flask-SqlAlchemy - error - Foreign Keys

Python Flask SqlAlchemy Error Hi guys. I hope someone can help me. I am just an student building my first Database for project that i have to submit. My project is a Book Review built in Flask, ...
0
votes
0answers
19 views

How does one write to a MySQL database using Flask-SQLAlchemy from a Celery worker?

I am looking for a concept here. If I use Flask's db.session object in the Celery task (from extensions import db; long_function_that_deals_with_stuff_in_db(); db.session.commit()), there is no ...
1
vote
1answer
159 views

how to query files from a course of which a student is a part?

On the profile page of user I want to display the files of the course of which he is part of. Here is the code in flask and flask_sqlalchemy I have written in my models.py I have got below code ...
0
votes
0answers
11 views

How do I include dynamic URLs in flask-sitemap?

I'm using Flask-sitemap and I can create a sitemap but the sitemap only includes my static pages. How do I get my dynamically generated URLs into the sitemap? Example of how I dynamically generate ...
0
votes
0answers
27 views

SQLAlchemy ORM to load specific columns in Model.query

I am newbie in python/sqlachemy world. I am trying to fetch data from PostgreSQL using sqlachemy in flask, where I need to fetch only selected column instead of streaming all the column from database ...