V
V
vaflya2019-06-19 19:37:46
Python
vaflya, 2019-06-19 19:37:46

How to get last row field value in peewee?

from peewee import *

class Names(WishModel):
    ka_id = IntegerField()
    name_ru = CharField(null=True)
    name_en = CharField(null=True)

Names.select().order_by(Names.ka_id.desc()).get()

I do not quite understand how to get the "ka_id" of the last added line, please tell me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vaflya, 2019-06-19
@vaflya

Answered my own question, couldn't find it online.
It is very important to specify in what form to return the results, here in tuples, you can in get () - then get the id of the entry

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question