The simplest way is: ``` cpf = request.params["cpf"] rows = request.dbsession.query(Paciente).filter(cpf=cpf),all() ```
This doesn't do any validation or graceful error reporting on the input value, so you may want to use Colander or FormEncode for that. I use FormEncode. Otherwise invalid input may lead to a Python exception and an Internal Server Error for the user, and 'cpf' will be a string even if the database field is integer. On Wed, Nov 22, 2023 at 1:34 PM Oberdan Santos <sc.ober...@gmail.com> wrote: > > Hello!!! I'm trying to make the code below work as follows. > When filling out the data entry, click on the query button. > > # template/pac_recepx. jinja2 > > <div class="form"> > <div class="row g-2 mt-3"> > <h3><span class="font-semi-bold">Consultar cadastro do > paciente</span></h3> > </div> > <form class="form-inline my-2 my-lg-0" > action="http://localhost:6543/queryx" method="GET"> > <label for="cpf">Digite o CPF (11 números)</label> > <input class="form-control mr-sm-2" type="text" id="cpf" > name="cpf" required maxlength="11" value=''> > <button class="btn btn-outline-success my-2 my-sm-0" > type="submit">Consultar</button> > </form> > </div> > > In this view, using the code below, it shows all registered patients. > > @view_config(route_name='queryp', > renderer='piprdc:templates/pac_query.jinja2') > def queryp(request): > rows = request.dbsession.query(Paciente).all() > pacientes=[] > for row in rows: > pacientes.append({"id":row.id, "name":row.name, "idade":row.idade, > "data_nascimento":row.data_nascimento, "sexo":row.sexo, > "raca":row.raca, "fone":row.fone, > "endereco":row.endereco, "cpf":row.cpf, "cns":row.cns}) > return{'pacientes':pacientes} > > The question is, how do I make it show only the patient I requested the > appointment with? I've looked at a lot of content, but I can't create a logic > for it to take the past information (cpf), compare it and display it. > > Every help is welcome. > > Oberdan costa > > > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/25b36bc3-0c71-4587-b79f-dfb26e83e7f7n%40googlegroups.com. -- Mike Orr <sluggos...@gmail.com> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3DupkZ8LkurvA-zShkYF4PORqtCW%3D0dDSbshjTUW87PSdEw%40mail.gmail.com.