7,051 questions
2
votes
2
answers
74
views
"TypeError: expected string or bytes-like object, got 'type'" error with SQLAlchemy query
(I'd tried to post this here, had someone post a version of it for me on r/flask, and am trying again here, so please excuse the duplication if the original one shows up.)
I'm trying to modify a Flask/...
0
votes
0
answers
31
views
How to connect to MySQL database with SQLAlchemy when running the application and MySQL running as a Docker container? [duplicate]
I am trying to run an application as its Docker image. It needs to access the database on the server. I am trying to run everything on a remote server and it is a Linux server. I am using docker ...
1
vote
0
answers
90
views
Memory Leak in Flask-SQLAlchemy 2.5.1 with SQLALCHEMY_RECORD_QUERIES - sqlalchemy_queries List Growing Indefinitely
Environment
Flask: 2.0.3
Flask-SQLAlchemy: 2.5.1
SQLAlchemy: 1.4.41
Deployment: Gunicorn with thread workers
Traffic: ~4 RPS in production
Observed Issue: Memory grows from 35-40% to 90% over 30 ...
1
vote
0
answers
90
views
SQLalchemy NOT NULL constraint failed on primary key
I am making an inventory database using SQLalchemy, but have some struggles with it. My code looks like this:
@cross_origin
@app.route('/api/add_item_loan', methods=['POST'])
def add_item_loan():
...
1
vote
1
answer
64
views
Flask SQL model missing one positional argument
from flask import (Flask, render_template)
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://user:password@localhost/database'
db = ...
-1
votes
3
answers
73
views
whenever i hit post request on my page then I cannot display the updated value from database even though I fetched the data from updated db
This is my code and inorder to fetch the correct result i have to either refresh or render the user.html again to reflect the changes.
is there any way to do it more efficiently
I tried rendering the ...
2
votes
2
answers
110
views
How to convert a datetime to period
How can I format a datetime in HTML from flask render_template so it displays how much time has passed since the datetime?
I am getting cabinet table from flask_sqlalchemy where the date is formatted ...
0
votes
0
answers
32
views
How to copy all attributes from one row to another existing row with SQLAlchemy ORM [duplicate]
I'm trying to implement a profile-based persistent config for a webapp using flask-sqlalchemy. My idea is to back this using a ConfigProfiles table that will contain all admin-created profiles plus a &...
0
votes
1
answer
41
views
how to query a flask sqlalcheme tha has two relationship from another single table
I am trying to query a table that contains userId, which references users, and taggedNameId, which also references users and view it in my template. But i keep getting this error "int object' has ...
0
votes
1
answer
52
views
How can I access current_user outside of an route. FLASK API
Im trying to make a polling mechanism, so im making a background process using "ThreadPoolExecutor", I added a status boolean to my users table so they will only be able to send 1 request at ...
0
votes
1
answer
106
views
Getting AttributeError: 'tuple' object has no attribute 'items' while creating a new item in flask sql alchemy in flask admin
I have created two models in flask-sqlalchemy Product and Brand. Both have a relationship to each other. Whenever I try to create a brand I get the error AttributeError: 'tuple' object has no ...
0
votes
0
answers
53
views
RuntimeError: The current Flask app is not registered with this 'SQLAlchemy' instance
I'm having troubles to init my app on flask. It says "Did you forget to call 'init_app', or did you create multiple 'SQLAlchemy' instances?" I call init_app as "db.init_app(app)" ...
1
vote
1
answer
106
views
I cannot create table using SQLAlchemy
I have a table with a few columns in an empty database and then db.create_all() with with app.app_context()but when I run the code, the database is still empty and there are no tables.
CODE EDITOR: ...
1
vote
1
answer
78
views
Optimizing SQLAlchemy Flush: Intercepting INSERTs for Batched Multi-Row Execution in MySQL
Is there a way to monkeypatch SQLAlchemy in a way that intercepts all INSERT INTO statements generated during a session.flush() without sending them to the database? Instead, I want to capture these ...
0
votes
0
answers
31
views
Copy an sqlite database into memory using SQLAlchemy 3.2 [duplicate]
Martyn posted this 3 years ago; how to copy an SQLite db into memory:
Stackoverflow question
# open existing db
old_db = sqlite3.connect('app.db')
# get the connection to the in memory db
conn = db....