flask-sqlalchemy

What is the best way to update all clients when Flask database changes without polling?

◇◆丶佛笑我妖孽 提交于 2020-01-22 03:32:28
问题 Currently I have a Flask server that runs a small web frontend as well as a command line interface to that same server. The basic idea looks like this: <Top section: allows file upload> * list of files from database <Second section: allows file manipulation/ upload> * list of files from database <Third section: Not files, but still allows for database changes> * list of things made from database Now this works well from the front end, but currently if the CLI or another client makes a change

Join tables in two databases using SQLAlchemy

半腔热情 提交于 2020-01-19 13:04:53
问题 I am working with two MySQL Databases. I want to join a table from DB 1 with a table from DB2 in SQLAlchemy. I am using automap_base while creating data access layer in sqlalchemy as follows... class DBHandleBase(object): def __init__(self, connection_string='mysql+pymysql://root:xxxxxxx@localhost/services', pool_recycle=3600): self.Base_ = automap_base() self.engine_ = create_engine(connection_string, pool_recycle = pool_recycle) self.Base_.prepare(self.engine_, reflect=True) self.session_ =

Join tables in two databases using SQLAlchemy

為{幸葍}努か 提交于 2020-01-19 13:04:03
问题 I am working with two MySQL Databases. I want to join a table from DB 1 with a table from DB2 in SQLAlchemy. I am using automap_base while creating data access layer in sqlalchemy as follows... class DBHandleBase(object): def __init__(self, connection_string='mysql+pymysql://root:xxxxxxx@localhost/services', pool_recycle=3600): self.Base_ = automap_base() self.engine_ = create_engine(connection_string, pool_recycle = pool_recycle) self.Base_.prepare(self.engine_, reflect=True) self.session_ =

psycopg2 error on Google App Engine

跟風遠走 提交于 2020-01-17 07:02:31
问题 I'm hosting a website/app using Flask/SQLAlchemy on Google's App Engine, part of which entails communicating with a PostgreSQL server and querying it to populate the website. The SQL server is hosted on Google's Compute Engine as a VM instance per these instructions, but with the server open to all connections. When I send a GET request to the website/app when it is hosted on localhost, I get the data I expect. However, when I launch the app and attempt to send the same request to the new URL

flask security separating access data on flask admin

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 18:18:08
问题 i have an aplication homestay reservation built with flask.. every homestay have an user login, this login built with flask-security and every owner of the homestay have role User . and every user can input their homestay data with flask-admin. but unfortunately if a user input their data, the others user which have role User can seing the data have input too.. so.. my question how to separate the data if a user have the same role..? user A can just see his data, and user B so too.. this is

Flask-SQLAlchemy: SQLALCHEMY_ENGINE_OPTIONS not set up correctly

主宰稳场 提交于 2020-01-16 05:33:37
问题 I just updated my projects Flask-SQLAlchemy Version to the latest one (v2.4). As some of the SQL-Alchemy config parameters were deprecated, I now follow the documentation and added SQLALCHEMY_ENGINE_OPTIONS as a dictionary to my config class. However, when I try to query the database I get an error. I was looking up the exact keywords needed for sqlalchemy's create_engine(). Here is my config class: class ConfigAPI: try: SQLALCHEMY_DATABASE_URI = os.environ['MYSQL_URI'] except KeyError as e:

Flask Admin - performance difficulties

送分小仙女□ 提交于 2020-01-16 03:25:07
问题 I am facing to performance problem in Flask-Admin, although performance of Flask application is good. my model is: class Ck(Base): __tablename__ = "ck" id = Column(Integer, primary_key=True, autoincrement=True) nazev = Column(String(100)) kontakt = Column(Text) terms = relationship(Term, backref=backref('ck', lazy='noload'), lazy='dynamic') class Term(Base): __tablename__ = "term" id = Column(Integer, primary_key=True, autoincrement=True) hotel_id = Column(Integer, ForeignKey('hotel.id')) ck

SQLAlchemy's automap_base creates bad collections for one-to-many tables

百般思念 提交于 2020-01-15 09:21:26
问题 I am using Flask-SQLAlchemy to recreate tables in an existing SQL Server database. The usual declarative base wasn't working out so I am trying to use the automap base. My DB has a table called 'orders' and I am trying to query the data: db = SQLAlchemy(app) db.Model.metadata.reflect(bind=db.engine) Base = automap_base() Base.prepare(db.engine, reflect=True) db.session.query(Base.classes.orders).all() However, an ArgumentError is thrown: ArgumentError: orders.orders and back-reference orders

Flask-SQLAlchemy - TypeError: __init__() takes only 1 position

拈花ヽ惹草 提交于 2020-01-15 08:20:13
问题 I just want to create and test db with flask-sqlalchemy. DB created yet succesfuly. My code: class Entry(db.Model): id = db.Column(db.Integer, primary_key=True) occurences = db.Column(db.String(80), unique=True) a = Entry('run.py:27') Error: a = Entry('run.py:27') TypeError: __init__() takes 1 positional argument but 2 were given If I trying to do this without arguments program returns this: qlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: entry [SQL: 'INSERT INTO

apscheduler cron job is not executing

核能气质少年 提交于 2020-01-15 07:47:13
问题 I am using apscheduler with a persistent job store through sqlalchemy in a flask application. flask-sqlalchemy module is being used. Jobs without triggers and a persistent job store are executing. However, with cron jobs, the 'next_run_time' is always updated but the job does not execute. In case of misfire, I want the job to only run once. ## relevant global config variables for flask app SCHEDULER_EXECUTORS = { 'default': {'type': 'threadpool', 'max_workers': 20} } SCHEDULER_JOB_DEFAULTS =