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

Retrieve id after .commit()

I am trying to pick up SQLalchemy and run constantly run into the following problem: is there a way to retrieve some sort of a metadata string from session.commit(), which contains the current primary id SQLalchemy just created ?
baconStrips
  • 101
  • 9
2
votes
1 answer

Flask-sqlalchemy; filter a query by list of foreign keys

My postgres db has classes Category and Product. A Category can have many Products. I am trying to get the products that belongs to a list of multiple categories (full_tree is a list of the id's of the categories). My attempted queries doesn't seem…
Drublic
  • 660
  • 1
  • 9
  • 23
2
votes
2 answers

How to delete flask migration folder and table

I want to fully delete the database and all the tables I have created. I tried everything. table_instance.table.drop(engine) I tried creating another project and reinstalling flask-migrate I still got No such revision '39408d6b248d' error and no…
kreki
  • 51
  • 2
  • 4
2
votes
1 answer

Flask-migrate No changes in schema detected

I am trying to understand how flask and sqlalchemy works.Below is my app structure init.py contains import os from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import…
2
votes
1 answer

Flask Login with Multiple User Classes and SSO

Flask beginner here. I have three user classes for my flask-login. GoogleUser and FacebookUser utilize SSO and does not require the password field: from InstaFlix import db, login_manager from datetime import datetime from flask_login import…
Willie Jones
  • 23
  • 1
  • 6
2
votes
1 answer

How to make the filtering queries more efficient using flask sqlalchemy?

I have a following table in a flask app class Price(db.Model): __tablename__ = "prices" id = db.Column(db.Integer, primary_key=True) country_code = db.Column(db.String(2), nullable=False) value = db.Column(db.Float(precision=2),…
reinhardt
  • 1,873
  • 3
  • 9
  • 23
2
votes
1 answer

How to know which form is submitted to the flask web server

This code is very big, in this code I am taking data from forms and I don't know from which form the user has triggered the button. So, in code I am identifying where it has values and where not which has make my code big that's a very awkward and…
2
votes
1 answer

in Sqlalchemy can I add a column with "source table" name in union?

I have these two tables - sales and purchases. And then "stock" which is related to them. This is Flask-Sqlalchemy by the way, but I don't know if that's important. class Sales(db.Model): __tablename__ = "sales" id = db.Column(db.Integer,…
Alma
  • 99
  • 8
2
votes
0 answers

How to select records containing given value in a JSON array in PostgreSQL JSON field using SQLAlchemy?

I have items (users) in a PostgeSQL database with JSON data field with such structure: { "department": [ "IT" ], "competencies": [ "moderator", "language_ru", "language_en" ] } Database is accessed using flask-sqlalchemy.…
Yuriy Petrovskiy
  • 7,888
  • 10
  • 30
  • 34
2
votes
1 answer

Variable value in search box is lost when displaying records with pagination using Flask

Problem description: I have a list of swimmer names stored in Sqlite db at the swimmer table. The list is displayed to the user when clicking on home menu. When the swimmers option is selected from the menu the list of swimmers is displayed using…
Ramiro
  • 369
  • 3
  • 14
2
votes
1 answer

TypeError: get_bind() got an unexpected keyword argument

I am trying to use a database in flask using from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker In it I am created a basic login page and a register page and when I try to use html code:
Chris
  • 704
  • 1
  • 11
  • 32
2
votes
2 answers

Flask Sqlalchemy how to not auto-update TIMSTAMP column when update a row

I have a model: class User(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) password = db.Column(db.String, nullable=False) created_time = db.Column(db.TIMESTAMP,…
Natarich J
  • 407
  • 2
  • 5
  • 17
2
votes
0 answers

How to check Flask-SQLAlchemy multiple choice question answer with database

I'm building a multiple choice question quiz web app using Flask and storing it using sqlite flask-sqlachemy. I have the following database at the moment. I also managed to display the question with below template and routes. I'm not sure how to…
xhackerz
  • 43
  • 3
2
votes
1 answer

SQLite does not create a table in Flask application

I have written a test Flask script that only prints hello world to the screen, which works fine. Now I decided to test the SQLite database by first creating the database tables. However, it seems create_all create the database with no errors but…
math
  • 341
  • 4
  • 14
2
votes
0 answers

SQLAlchemy getting default's column label name out from result set

I want to select data from the user and account tables. there are id and name column which exists in both tables. so SQLAlchemy applies labels while querying into the database. for e.g query=(User.name, User.id, Account.name,…
Sudhakar
  • 324
  • 3
  • 9