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

Serializing SQLAlchemy with Marshmallow

I'm following a tutorial and using the below code. I'm also using Postman to view the status of the server for http://localhost:5000/planets , but I'm getting 500 INTERNAL SERVER ERROR, when I should see my JSON data of the planets I created. In the…
2
votes
1 answer

flask-sqlalchemy. PhoneNumber type

models.py class User(db.Model): id = db.Column(db.Integer, primary_key=True) Name = db.Column(db.String(80), nullable=False) # Phone = db.Column(), nullable=False) what kind of type can be here? I found a solution when using…
gohxr
  • 101
  • 3
  • 10
2
votes
1 answer

Create distinct SQLAlchemy sessions between integration test (Pytest) and Flask application

I have flask application (RESTful API backend) that uses flask-sqlalchemy lib. The integration test uses Pytest with fixtures, some create records for test purposes. The problem is that when testing scenario that's expected to raise unique…
andy
  • 51
  • 2
2
votes
0 answers

How to use flask-migrate to migrate multi database with different table

I'm using Flask-SQLAlchemy connect to multiple databases. class Car(db.Model): id = db.Column(db.Integer, primary_key=True) brand = db.Column(db.String(80), unique=True) class Dog(db.Model): __bind_key__ = 'database_2' id =…
2
votes
1 answer

Flask-Dance SQLAlchemy integration not working

I'm using Flask-Dance to use Google to login to my application. I am also using SQLAlchemy and Flask-Login. Everything regarding the Google login is working perfectly but it is supposed to save the token data in a table created by SQLAlchemy…
plasmy
  • 99
  • 3
  • 9
  • 32
2
votes
2 answers

Flask SQL no such table

I've tried this before and it worked, now I'm doing it again but it doesn't. I use a virtual env. The db file is in the same directory as the init and models. I've also executed the db.create_all() in the python shell after importing db. The error…
roocs
  • 43
  • 1
  • 9
2
votes
1 answer

How do I properly edit Alembic migration scripts in Flask-Migrate/Flask-SQLAlchemy to add or edit columns?

I have a little app I'm using to scrape data from online articles. Currently, I am trying to figure out how to edit the migration scripts from Flask-migrate so I don't have to delete all the migration data and the SQlite database then re-scrape the…
2
votes
1 answer

flask-sqlalchemy query using function of row values

I have two tables, Student and Result, with a one to one relationship. The Student table will eventually contain full student profile information, and the Result table is maths and english test results for each student. class Student(db.Model): …
thebitsdontfit
  • 113
  • 1
  • 6
2
votes
2 answers

How to filter a SQL query on columns in SQLAlchemy?

I am new to flask-alchemy. I want to filter a SQL query on the values of a LOC_CODE column. I made db.session.query(schools).filter_by(LOC_CODE='X270').first(). But the compiler returns: (base)…
2
votes
1 answer

Alembic recreates foreign keys every time I migrate causing duplicate foreign keys on my tables

I have a flask app using sql-alchemy and flask migrate to handle database changes. Every time I run a flask migrate to create a script for Alembic to update the database, the script contains commands to create foreign keys that already exist in my…
2
votes
1 answer

Will Flask-Migrate migrations work across different database engines?

I am writing a Flask application that uses Flask-SQLAlchemy and Flask-Migrate. Production has a PostgreSQL database, but for development, I was hoping to use SQLite instead of having to install full PostgreSQL on my development machine. I set up…
Dominick Pastore
  • 4,177
  • 2
  • 17
  • 29
2
votes
1 answer

How to create a new schema from a flask application

I have flask application,I'm trying to achieve multi-tenancy by multiple schema for users. When a user sign up, i'm trying to create a new schema with the username from the application and creating new two table in that particular schema. i can…
Abhishek Aravindan
  • 1,432
  • 6
  • 23
2
votes
3 answers

Flask-SQLAlchemy Many-to-many relationship : How to insert data

I have created a many-to-many relationship in my Flask-Sqlalchemy models. However it seems that I don't well understand how to fill my database. Could you please tell me how I suppose to write my code to fill my database correctly? Here are my…
2
votes
1 answer

Access SQLAlchemy class field inexplicitly and fix 'object is not subscriptable' error

I'm developing my first Flask app using SQLAlchemy models, I've got around 10 classes representing database tables and the classes have fields representing columns. Now in my app.py I'm trying to make a selection of data from the database and get it…
Theta
  • 231
  • 2
  • 14
2
votes
1 answer

why the stored procedure called from sqlalchemy is not working but calling from workbench is working?

I have a stored procedure. calling it via MySQL workbench as follows working; CALL `lobdcapi`.`escalatelobalarm`('A0001'); But not from the python program. (means it is not throwing any exception, process finish execution silently) if I make any…
Ratha
  • 9,434
  • 17
  • 85
  • 163