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

Flask_SQLAlchemy Cannot reflect Database like SQLAlchemy

I'm trying to connect Foreigner Database to a python-Flask app using Flask_SQLALchemy I looked everywhere including the FLASK_SQLALCHEMY official doc I've been looking everywhere over the internet for the past 4 days for any tutorial that…
LoopingDev
  • 754
  • 2
  • 10
  • 32
2
votes
1 answer

Flask SQLAlchemy import DB import

I am using flask with SQLAlchemy, after set all configuration setting I got db import error on model. ImportError: cannot import name 'db' my main app __init__ from flask_api import FlaskAPI from flask_sqlalchemy import SQLAlchemy import os import…
vipin
  • 2,374
  • 1
  • 19
  • 36
2
votes
1 answer

Avoid circular imports in Flask/SQLAlchemy when querying related model

I'm using Flask-SQLAlchemy with blueprints, in a setup based on cookiecutter-flask, which gets around most circular import problems. However, my situation is the following. I have two related (actually, it probably doesn't matter if have a database…
Mark
  • 1,306
  • 13
  • 19
2
votes
1 answer

SqlAlchemy Continuum: history and transaction tables are not created

I am trying to integrate sqlalchemy-continuum versioning into an existing application that uses flask-sqlalchemy. I have a __versioned__ = {} to the models I want to have versioned e.g.: class User(Base): __versioned__ = {} __tablename__ =…
2
votes
2 answers

How to create generated column in Flask-SQLAlchemy?

This SQL is OK CREATE TABLE `calendar` ( `dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `d` date as (dt), `t` time as (dt) ); How to create this table in Flask-SQLAlchemy? class Calendar(db.Model): __table_args__ = {'mysql_collate':…
CL So
  • 3,647
  • 10
  • 51
  • 95
2
votes
1 answer

Using python library flask-rest-jsonapi without id as primary key

I am using Python library flask-rest-jsonapi to design an API. The library uses flask-sqlalchemy and marshmallow. Marshmallow has a requirement to have an "id" and a "type" field mandatory in the schema. The database tables that I am designing APIs…
user2798227
  • 853
  • 1
  • 16
  • 31
2
votes
2 answers

How to select only some of the columns from the database with Flask-SQLAlchemy?

I'm developing an API with flask_restplus and flask_sqlalchemy, and I have a special case where certain applications should access only certain columns from the API. I have a model: class MyModel(db.Model): __tablename_ = 'my_table' id =…
UrmLmn
  • 1,099
  • 2
  • 16
  • 28
2
votes
1 answer

MySQL data is caching with google cloud SQL and SQLAlchemy

This is my first question on stackoverflow, so please correct me if I do something wrong :). My data from a database hosted at Google Cloud SQL is caching with Flask-SQLAlchemy. When I add a new record and try to get that record it doesn't exist. I…
2
votes
3 answers

How do I produce nested JSON from database query with joins? Using Python / SQLAlchemy

I have a specify use case but my question pertains to the best way of doing this in general. I have three tables Order - primary key order_id OrderLine - Linking table with order_id, product_id and quantity. An order has 1 or more order…
Andrew Allen
  • 6,512
  • 5
  • 30
  • 73
2
votes
1 answer

Docker error in running postgres connection string (for SQLAlchemy) with sslmode

I have a python app the connects to AWS RDS. The connection string allows me to run the app in a Docker with no issues: postgresql://:@/ The following 2 connection strings runs with the error…
NotMe
  • 745
  • 2
  • 7
  • 26
2
votes
0 answers

How to handle row edits with multiple users logged in

I've built a 2 end point flask backed using flask sqlalchemy, where one end-point is for getting the data another for updating the data. Now the question is, how do I ensure that the same row which is pulled for editing is not being served to…
Ven
  • 57
  • 5
2
votes
1 answer

"Flask Sqlite Database not showing the queries"

I am coding a web application which is adoption site for puppy, where there are features like Adding puupy, deleteting after adoption. But this is not showing/displaying the puppies added in the database. I am beginner so i am even unsure whether…
2
votes
1 answer

Unknown MS Compiler Version 1916 - I'm trying to run Python with Flask and getting this error

I had opened the file cygwinccompiler.py and the thing is, the version 1916 isn't handled within that file. I'm new programming with Python and Flask, and I'm stuck in this point since yesterday. I would like to know with some Windows user got the…
TBR920
  • 77
  • 7
2
votes
0 answers

SQLAlchemy: change schema used by engine

I know it is possible to specify the schema in the URL used at engine creation. In this case every connection generated by the engine will be already using the specified database: engine = create_engine('mysql://%s:%s@%s:%d/%s' % (user, pwd, host,…
ttk203
  • 347
  • 5
  • 10
2
votes
0 answers

flask-sqlalchemy: DB disconnection issue

I use a 24/7 running flask application with sqlalchemy and postgres DB. If the DB server goes down (e.g. AWS RDS installs minor upgrades) the (single worker) flask application hangs permanently. I initialize the SQL extension like this: from…
caliph
  • 1,389
  • 3
  • 27
  • 52
1 2 3
99
100