-
Hi, i have questions. In old sqlalchemy query, after insert we can have return object full of data what we insert, but in this query only return the id of row. How i can get return object with full of data ? @database.transaction()
async def create(self, *, obj_in: DeviceCreate) -> Device:
obj_in_data = jsonable_encoder(obj_in)
installed_app = obj_in_data.pop("installed_applications")
query = insert(self.model).values(
**obj_in_data, installed_applications=json.dumps(installed_app)
)
return await database.execute(query=query)
# return --> 6 (id of row) |
Beta Was this translation helpful? Give feedback.
Answered by
aminalaee
Oct 26, 2021
Replies: 1 comment 1 reply
-
Hi @dvrg I think what you want to do is beyond what a driver like |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dvrg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @dvrg
As far as I know this is the expected behaviour. You need a separate query to select all columns with the returned id.
I think what you want to do is beyond what a driver like
databases
will do. You need to use an ORM like orm to do that for you.