Read slave, read-write master setup

I have a Flask, SQLAlchemy webapp which uses a single mysql server. I want to expand the database setup to have a read-only slave server such that I can spread the reads between both master and...

ImportError: No module named sqlalchemy

I'm unable to find a module in python ,though easy_install says its already installed. Any idea how to resolve this isseue? $ python -c "from flaskext.sqlalchemy import SQLAlchemy" Traceback (most...

Common folder/file structure in Flask app

I have just created a flask application and so far I have a router for my "Hello world!" template. I would like to add a little (a lot) more functionality, but I wonder how I should structure the...

How can I define relationships for my models in flask

I am new to flask and ORM technology and am doing one sample project for my learning. In my application, a trainer can teach one or more technologies, so I define my tables as...

I'm not able to import Flask-WTF TextField and BooleanField

I'm using virtualenv to set up a new project. I installed a lot of things using virtualenv pip from the script folder like below: flask\scripts\pip install Flask-WTF I have no other packages...

unable to create autoincrementing primary key with flask-sqlalchemy

I want my model's primary key to be an autoincrementing integer. Here is how my model looks like class Region(db.Model): __tablename__ = 'regions' id = db.Column(db.Integer,...

SQLAlchemy: Any constraint to check one of the two columns is not null?

This may be totally stupid thing to ask but I have such a requirement in my model where atleast either category or parent_category is not null My model looks like class...

flask-sqlalchemy model property to string

I have the following code: from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy(app) class Product(db.Model): id = db.Column(db.Integer, primary_key=True) name =...

Flask, SQLAlchemy: How to make column autoincrement

I'm defining a model like this: class User(UserMixin, db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) first = db.Column(db.String(64)) last =...

Leaking database connections: PostgreSQL, SQLAlchemy, Flask

I'm running PostgreSQL 9.3 and SQLAlchemy 0.8.2 and experience database connections leaking. After deploying the app consumes around 240 connections. Over next 30 hours this number gradually grows...

SQLAlchemy - performing a bulk upsert (if exists, update, else insert) in postgresql

I am trying to write a bulk upsert in python using the SQLAlchemy module (not in SQL!). I am getting the following error on a SQLAlchemy add: sqlalchemy.exc.IntegrityError: (IntegrityError)...

How to clone a sqlalchemy db object with new primary key

I want to clone a sqlalchemy object: I tried it by product_obj = products.all()[0] #here products is service name product_obj.product_uid = 'soemthing' #here product_uid is the pk of product...

SQLAlchemy delete() function flushes, but does not commit, even after calling commit()

I have a flask app that uses sqlalchemy to read, write a postgres schema. When i use the .delete() function, it only flushes, but actual changes to the database do not occur. Session =...

python - Flask-sqlalchemy: sqlalchemy.exc.InvalidRequestError

I'm building a backend for my iOS app and I choose to use Flask framework. For the database part, I use flask-sqlalchemy to connect my mysql database. When I put all my test code in a single file,...

alembic + sqlalchemy multiple databases

Within Flask i have setup SQLAlchemy to use multiple databases which are selected upon request as described in https://quanttype.net/posts/2016-03-15-flask-sqlalchemy-and-multitenancy.html So...

H14 error in heroku - "no web processes running"

error H14 happen while deploying to heroku this is my procfile: web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent main:app log on heroku: 2017-01-23T10:42:58.904480+00:00 heroku[router]: at=error...

SQLALCHEMY_DATABASE_URI not set

I tried to work with CURD operation using Flask and SQLAlchemy.But getting Error while connecting to database. Here is the Error...

one hot encoding for frequent values only

I am looking to do one hot encoding to a column, but only for those that are very frequent. All that are below a threshold T will be put in their own category. My strategy was to create a...

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table

I am fresh to flask and was trying to build a blog on my own, and I ran into an issue with SQLite operation error. I have researched similar problem on Github and Stackoverflow but none of the...

Get the inserted primary key ids using bulk_save_objects

How can I get the inserted Ids (primary key generated) after using session.bulk_save_objects? I tried this: for x in y: obj = Post(...) ...

Flask testing - "RuntimeError: No application found” when trying to connect with db with SQLAlchemy

Im writing test code with pytest for testing API written with python 3. But Im struggling with the below error message. The python code correctly works without pytest but the error message comes...

app.shell_context_processor decorator does not register the function as a shell context function

I created the following function in a microblog.py file in my ~/Programing/Rasa/myflaskapp/app folder. It creates a shell context that adds a database instance and models to the shell...

How to delete all users in Airflow?

I am setting up web authentication for Airflow web server. I added a few users following the guidance of the official guide. Now I want to delete all users that have been added, what should I...

TypeError: 'Product' object is not subscriptable in Flask

I am new to python and flask, I am learning to build Flask-rest-api. I am using SQLAlchemy as the db. I tried to post data using postman to the api and I get the TypeError: Object is not...

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "users" does not exist

Im currently taking the cs50web course and i have to connect my flask app to heroku postgres database, i have already created the tables using pgadmin 4 but im not able to access the data. ...

PyCharm warns about unexpected arguments for SQLAlchemy User model

I'm working with Flask-SQLAlchemy in PyCharm. When I try to create instances of my User model by passing keyword arguments to the model, PyCharm highlights the arguments with an "Unexpected...

Redash Docker installation problem: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError)

I'm trying to install Redash on Ubuntu 20.04.1 I used this method of installing: https://github.com/getredash/setup I downloaded the files I cd in to the folder I run 'sudo ./setup.sh' I get the...

ImportError: "flask_sqlalchemy" could not be resolved

i'm unable to import flask_sqlalchemy even after installing flask-sqlachemy from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy # ^this line shows error ImportError:...

Marshmallow returning empty JSON after dumping

I am trying to implement a restful API with Flask using flask-restful, flask-sqlalchemy and flask-marshmallow. I am aware there are many questions about this issue but I still can't figure it...

NameError: name '_mysql' is not defined -- On airflow start in MacOSX

There are numbers of articles on the titled question but none of them worked for me. The detailed error is as follows: Traceback (most recent call last): File...