Seemingly out of nowhere, my Flask app is now inserting the same value for one column in a table in my database no matter what when it had been previously working. I have a model here: and code in my application: The result of the prints is So it looks like after the record is committed, the number changes and
Tag: flask-sqlalchemy
Flask-SQLAlchemy: ‘Table’ object has no attribute ‘query_by’
I’m developing an API with Flask and I cannot retrieve queries from a MySQL database I’ve connected with flask-sqlalchemy (not sqlalchemy alone). This is a pre-existing database downloaded from my client’s PHPMyAdmin, so I haven’t ran db.create_all(): I simply created the connection string in config.py, then instantiated db = SQLAchemy() and initialized it (db.init_app(app)) in my factory function (i’m using
Flask – how to call python function with parameters in button?
I am working on a notification system on my website. I decided to make a model in the database for them. I also made a function in views.py that takes an argument of a user that is receiving a notification and the type of notification. Here is the code: Now I want to be able to send the user a
Javascript store in session, get from session in python/flask
I am working with a flask app, and am trying to store a Json object using javascript, and retrieve it in python as i would like to store a sort of “shopping list” information that the user is generating, into my database. The object appears in my browsers session storage but it seems my syntax is off as im getting
What triggers the KeyError: ‘SQLALCHEMY_TRACK_MODIFICATIONS’?
I already looked at other threads concerning this error, which all indicate that this error is due to multiple instances of “app = Flask(name)”. But since I only have one, I hope someone here can help me figure this one out. I try to keep the code minimal, but enough to reproduce the error routes.py: models.py: create statements for the
SQLAlchemy Model.query.get use generic function to get latest id
Consider this snippet. I am trying to get the user with the latest id like this: It throws an error saying Boolean value of this clause is not defined How do I get the user with the largest id by using the model.query API? Answer I would solve it like: An alternative would be:
How to create multiple routes dynamically for same function and pass data which is fetched on the basis of Unique ID to single template in FLASK
I am a newbie to FLASK. I am creating an e-commerce site in flask and I want to create multiple routes dynamically for same function and pass data which is fetched on the basis of Unique ID to single template in FLASK. Let me explain it. I have a table in DB as below: id category slug 1 cat1 slug1
SQLAlchemy SQL expression with JSONB query
I have the following property on a flask-sqlalchemy model. I want to make this approved_at property a sortable column in flask-admin, but apparently I need to convert this to a hybrid property using SQL expressions. I don’t know how to convert this query into a sqlalchemy SQL expression, since it’s pretty complex with the JSONB query in it. I’ve looked
Get cpu, memory, disk data using Python script from node exporter metrics
Currently I am developing a python flask application. I need to get cpu, memory, disk data of the machine. I suppose to get those data using node-exporter using Python scripts. Currently I am working with dummy data. Here are the instructions provided: Select two simple metrics Send http call to node exporter and save coutput to a file or keep
SQLAlchemy require primary key to be generated by program
When defining a table, you define one column as primary_key=True. As shown in the tutorial, SQLAlchemy will automatically create an ID for an item, even when it is not supplied by the user. The primary_key=True also automatically sets nullable=False. Is there a way that I can set up the Primary Key so that it is required, but is not filled