Tags "sqlalchemy" Result

SQLAlchemy / Flask / PostgreSQL pool connection

After having played for a long time with Django, I'm trying a bit of Flask with SQLAlchemy, and I must say I quite like it. However there is something that I don't get: I have a small Flask / SQLAlchemy app that uses PostgreSQL. In my __init__.py file I have: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__

it1352 5 2019-05-17

Flask-SQLAlchemy create_all()

When i run the dbManager.create_all() command, it runs with out errors but fails to create the tables. When i delete the database and run the create_all() command, i get the no such database as ##### error which i should get but when the database does exist, nothing happens. Please can anyone see what i'm doing wrong? from blogconfig import dbMana

it1352 0 2019-05-17

One-to-one relationship in Flask

I'm trying to create a one-to-one relationship in Flask using SqlAlchemy. I followed this previous post and I created the classes like ones below: class Image(db.Model): __tablename__ = 'image' image_id = db.Column(db.Integer, primary_key = True) name = db.Column(db.String(8)) class Blindmap(db.Model): __tablename__ = 'blindmap'

it1352 3 2019-05-17

How do I declare a base model class in Flask-SQLAlchemy?

I would like to declare a base class that all other schema objects can inherit from, for example: class Base(db.Model): created_on = db.Column(db.DateTime, default=db.func.now()) updated_on = db.Column(db.DateTime, default=db.func.now(), onupdate=db.func.now()) Then all other schema objects can inherit from it and not have to repeat the

it1352 0 2019-05-17

Using same name of tables with different binds in Flask

I have two tables sharing the same name but located in different databases: class Lcn(db.Model): __tablename__ = 'lcn' class LcnRemote(db.Model): __bind_key__ = 'remote' __tablename__ = 'lcn' It seems SQLAlchemy doesn't like that. It says: sqlalchemy.exc.InvalidRequestError: Table 'lcn' is already defined for this MetaData insta

it1352 84 2019-05-17

Using SQLAlchemy session from Flask raises "SQLite objects created in a thread can only be used in that same thread"

I have a Flask view which uses SQLAlchemy to query and display some blog posts. I am running my app using mod_wsgi. This view works the first time I go to the page, but returns a 500 error next time. The traceback shows the error ProgrammingError: SQLite objects created in a thread can only be used in that same thread. Why am I getting this err

it1352 4 2019-05-17