How to set Row instance attribute

13 views
Skip to first unread message

sector119

unread,
May 6, 2023, 5:28:35 PM5/6/23
to sqlalchemy
Hello,

I get some data from DB and have a sequence of Row objects, how it is possible to modify data in those objects attrs?

Something like

result = await dbsession.execute(query)
services = result.all()

for i, service in enumerate(services):
    services[i].title = f"some text here {service.title}"

but I get AttributeError("can't set attribute")

Thanks

Mike Bayer

unread,
May 7, 2023, 9:46:05 AM5/7/23
to noreply-spamdigest via sqlalchemy


On Sat, May 6, 2023, at 5:28 PM, sector119 wrote:
Hello,

I get some data from DB and have a sequence of Row objects, how it is possible to modify data in those objects attrs?

you can't.   copy them to something you can modify



Something like

result = await dbsession.execute(query)
services = result.all()

for i, service in enumerate(services):
    services[i].title = f"some text here {service.title}"

but I get AttributeError("can't set attribute")

Thanks


--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages