I am developing a web application and trying to migrate from Spyder to VS Code. It was working with the default interpreter, so I created a new venv but when I start the server it does not work with the same code that was working without the venv. Error description:
File "C:\Users\User\Desktop\Flask\app.py", line 77, in index
measurement_mx = rs.all()
AttributeError: 'ResultProxy' object has no attribute 'all'
I installed exactly the same dependencies with pip install -r requirements.txt
.
Can you help me what the solution could be, I could not find this problem unfortunately.
Relevant code snippet:
@app.route('/', methods=['POST', 'GET'])
def index():
with engine.connect() as con:
rs = con.execute(SQL_string)
measurement_mx = rs.all() #this is the error line
measurement_list = []
for row in measurement_mx:
measurement_list.append(row._data)
measurement_list = transpose(measurement_list)
return render_template('index.html', measurement_list=measurement_list )
Thank you in advance!
The issue could be that your requirements.txt
file may specify what packages to install, but not their exact version, so could you please:
Some thoughts:
lock
file, see for instance this discussion on pip.lock
file)Now, concerning your exact issue: ResultProxy
is not an object from flask
but from SQLAlchemy
, which SQLAchemy v1.4 replaced:
class sqlalchemy.engine.Result(cursor_metadata)
Represent a set of database results.
New in version 1.4: The Result object provides a completely updated usage model and calling facade for SQLAlchemy Core and SQLAlchemy ORM. In Core, it forms the basis of the CursorResult object which replaces the previous ResultProxy interface. When using the ORM, a higher level object called ChunkedIteratorResult is normally used.
(emphasis mine)
Which means you can:
SQLAlchemy
version in your requirements.txt
file,SQLAlchemy
syntax.