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.

Armin Ronacher has developed Flask-SQLAlchemy as well as Flask itself, Jinja and Werkzeug. All of those written in Python. In the extension project main page the autor states:

Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy to your application. It aims to simplify using SQLAlchemy with Flask by providing useful defaults and extra helpers that make it easier to accomplish common tasks.

Flask-SQLAlchemy is open-source and hosted on Github

It's easy to setup and easier to use. You just have to install it via pip install Flask-SQLAlchemy or easy_install Flask-SQLAlchemy, and have the required software already installed.

After that you can test the installation and get a grasp of the basic usage with this quickstart tutorial.

7021 questions
2
votes
1 answer

Multiple foreign key paths linking the tables

I'm doing a MCQ question/answers db schema. But this gave me an error. I'm pulling my hair on this one. "Could not determine join condition between parent/child tables on relationship Question.options - there are multiple foreign key paths linking…
xhackerz
  • 43
  • 3
2
votes
1 answer

join multiple tables using SQLalchemy and assess it using Flask and Jinja

I'm looking to join 3 tables and selecting specific columns using Flask-SqlAlchemy in the front end to show all the details from the 3 tables. here's the models : class Venue(db.Model): __tablename__ = 'Venue' id = db.Column(db.Integer,…
IBRAHIM
  • 23
  • 3
2
votes
0 answers

Use multiple of the same flaskform categories on the same page, and submit them seperately to a database

I have a flaskform with the following categories: `class TestForm(FlaskForm): question: ('Question') likelihood = SelectField('Likelihood',choices=[('1','1'),('2','2'),('3','3'),('4','4'),('5','5')]) impact = SelectField('Impact',…
2
votes
1 answer

Flask SQLAlchemy bulk deleting records

I'm new to SQLAlchemy and I cannot work out how to delete multiple records at once. The documentation states that it is the same as .add() but using .delete() instead. It works if I append .first(), however I can't use .all() otherwise I get the…
edhog
  • 513
  • 2
  • 6
  • 25
2
votes
0 answers

Multiprocessing With Flask SQLAlchemy - error with status PGRES_TUPLES_OK and no message from the libpq

I am facing the below error when I use Python Multiprocessing with Flask-SQLalchemy. If I call the below method shown in target portion without multiprocessing, it works fine. This is the Error Message: Error seen in…
2
votes
1 answer

Flask-SQLAlchemy - assertionError when trying to reflect existing db when any relations exist

I am having hard time figuring out how to create models based on existing db tables with flask-sqlalchemy. I managed to do it with pure sqlalchemy's automap, but I want to be able to benefit from features of flask-sqlalchemy. I googled quite a lot…
sparx1989
  • 31
  • 3
2
votes
1 answer

flask sqlalchemy with circular imports with db models

backend ├── erp │   ├── blueprint_create_order_and_add_products │   │   ├── __init__.py │   │   └── resources │   │   ├── create_order.py │   │   ├── __init__.py │   ├── blueprint_general_query │   │   ├── __init__.py │   │   └──…
2
votes
2 answers

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) fe_sendauth: no password supplied

i am trying to run this simple flask app and I keep getting this error in the terminal when trying to run the flask app FLASK_APP=app.py flask run i keep getting this error : sqlalchemy.exc.OperationalError: (psycopg2.OperationalError)…
Ahmed
  • 413
  • 5
  • 9
2
votes
1 answer

'No application found. Either work inside a view function or push' RuntimeError: No application found

Before claiming this is a duplicate, I have searched through countless errors and I have not been able to find a solution that works for me. I have a flask web application that I am sql alchemy to facilitate the connection with my google sql…
2
votes
2 answers

How to automatically create database tables and schema with Flask and Sqalchemy?

I have a small Flask application. I add an extra security layer which is log in. I based my refactoring on the DO article. In a nutshell, __init__.py: from flask import Flask from flask_login import LoginManager from flask_sqlalchemy import…
Dmytro Chasovskyi
  • 3,209
  • 4
  • 40
  • 82
2
votes
0 answers

Handling 'Can't reconnect until invalid transaction is rolled back'

I have seen the other questions so I am going to jump straight to the point. My website is a blog built with flask, so of course I do operations like updating user info, adding new uploaded files etc. I always did those operations using app.db,…
G. Ramistella
  • 1,327
  • 1
  • 9
  • 19
2
votes
1 answer

sqlalchemy.exc.ResourceClosedError: This Connection is closed error

I cover the project with tests using pytest. In each application (module), I created the tests folder, inside which placed the files with the application tests. In each tests folder there are conftest fixtures for each application. When I run the…
unknown
  • 252
  • 3
  • 12
  • 37
2
votes
0 answers

How to group fields when serialising object with Marshmallow?

Problem How to group fields together when serialising a flat-structured SQLAlchemy object with Marshmallow without changing the flat data structure in the background? Example Suppose a SQLAlchemy model in a Flask app like this: from app import db #…
2
votes
1 answer

How (or where) do I call db.create_all() in a multi-file flask project?

I have a multi-file flask project where I have a single model and a couple routes. Initially, the project was just a single app.py file and I was able to just run db.create_all() within that file. Now that I have complicated imports with my…
thebork
  • 29
  • 3
2
votes
1 answer

How to save json type with flask-sqlalchemy?

I am currently developing an app using Flask + Vue. I use flask-sqlalchemy for ORM. When saving json to JSON type to MySQL, the action registers the data as a string versus a JSON object. Is it possible to save the value in JSON? Sample code: from…
nayuta shiba
  • 395
  • 1
  • 4
  • 10