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

What ways are there for seeding a Flask app?

I am about to deploy a very simple flask app on aws Elastic Beanstalk. What ways do I have to put some seed data so that the live instance has some users? from dateutil import parser from datetime import datetime from flask import Flask, request,…
irmaz
  • 51
  • 2
  • 4
2
votes
2 answers

flask db init Error: Could not import "app.run"

I am trying to initialise my db, and everytime i run the flask db init command, I get that error. I am unsure why, my FLASK_APP and FLASK_ENV are set correctly. I have been reorganising the project structure and file names to abide more with the…
LimitIt
  • 31
  • 1
  • 4
2
votes
2 answers

Reflecting different databases in Flask factory setup

I'd like to use Flask's application factory mechanism fpr my application. I have is that the databases I use within some blueprints are located differently, so I'm using binds for pointing to them. The tables itself are in production and already in…
brillenheini
  • 793
  • 7
  • 22
2
votes
0 answers

I'm trying to store a decimal number in a postgres database in flask using sqlalchemy and the number is rounded

Im trying to save a price variable in sqlalchmey but if its 78.6 it rounds up to 79.0 I've tried numeric and float datatypes and I'm using a postgresql heroku database db.Column(db.Float(precision=1,asdecimal=False,decimal_return_scale=None))
Amr Ayman
  • 21
  • 2
2
votes
2 answers

How to update records when many fields in Flask. Python

I am trying to update the record in the sqlite database, the values ​​that come in the query from the frontend: data: [{"cnt_doc":"17","code":"111","contragent":"Name1","contragent_id":2,"created_date":"Mon, 17 Jun 2019 18:54:37…
Ambasador
  • 365
  • 3
  • 14
2
votes
0 answers

Flask-Whooshalchemy not working: This session is in 'committed' state; no further SQL can be emitted within this transaction

I'm writing a script that imports some data from a CSV file into a Postgres database. The script is as follows: app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = app.config['WHOOSH_INDEX_PATH'] =…
UrmLmn
  • 1,099
  • 2
  • 16
  • 28
2
votes
0 answers

Flask SqlAlchemy Join returns just an ID value

Join returns just an ID value rather than the actual data. Relationship: 1 to Many = Client : PaymentHistory Issue: payment_history property is just 1, 2, 3 which is the ID of PaymentHistoy Expected Result: payment_history must contain actual data…
Vinay
  • 548
  • 2
  • 12
2
votes
1 answer

flask-jwt-extended TypeError: Object of type 'function' is not JSON serializable

I'm trying to make an API jwt authenticate with flask using flask_sqlalchemy and flask_jwt_extended,marshmallow to validate input data Login route to get token: from flask import Flask,request,jsonify, abort from flask_sqlalchemy import…
Linh Nguyen
  • 3,452
  • 4
  • 23
  • 67
2
votes
0 answers

Avoid 'using before assignment' issue when defining 'case' in SQLAlchemy

I have a Post model defined like this in flask-sqlalchemy: from datetime import datetime from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Post(db.Model): __tablename__ = 'post' id = db.Column(db.Integer, primary_key=True) …
funkid
  • 577
  • 1
  • 10
  • 30
2
votes
1 answer

SQLAlchemy: How can I update the table in the database when I update the model in models.py

I have as SQLAlchemy model called User and I want to add another property to the class, ex: address. I tried adding a new class property, and hoped that SQLAlchemy would realize there is a change in the class and would update the table…
Cap Lee
  • 43
  • 2
  • 10
2
votes
2 answers

Sqlalchemy filter by calculated datetime hybrid_property

I have a model Prescription. from datetime import timedelta from sqlalchemy.ext.hybrid import hybrid_property class Prescription(db.Model): """ docstring """ ID = db.column(db.Integer, primary_key=True) date = db.Column(db.DateTime) …
Sergey Miletskiy
  • 477
  • 2
  • 5
  • 13
2
votes
2 answers

How to return Flask-SqlAlchemy error details

I'm using Flask 1.0, Flask-SqlAlchemy 2 and Angular 7. When SqlAlchemy throws an error I want to show a tailored error message in the frontend. There is a section in the official Flask documentation about how to handle errors and also a similar…
user3255061
  • 1,757
  • 1
  • 30
  • 50
2
votes
1 answer

Flask-Sqlalchemy dynamic bind

I have the following config.py: SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///' + os.path.join(basedir, 'master.db') SQLALCHEMY_BINDS = { 'project0': 'sqlite:///' + os.path.join(basedir, 'project0.db') …
2
votes
0 answers

Sqlalchemy returning relationship with nested join using marshmallow

Currently I have a bunch of tables with clear relationships set up. However, I want one table (Application) that has a relationship to an Answer table and a Question table to only show answers that have Questions that are marked as active. I'm…
LittleBro
  • 61
  • 1
  • 5
2
votes
1 answer

How do I efficiency create big forms - FlaskForms

So I have an update form end point, which is very large, I've tried a few things to make it dynamically created to condense my code but I cant seem to figure it out. @customers.route("//update_customer", methods=['GET',…
Bob
  • 295
  • 5
  • 19
1 2 3
99
100