[Python-es] Seleccionar un solo elemento SQL

Diego Uribe Gamez diego.uribe.gamez en gmail.com
Lun Abr 30 21:19:26 CEST 2012


Gracias

sql = """select * from hospital_resgitro where id_usuario='42004790' limit
1"""

eso me da el resultado, solo se selecciona el ultimo registro ingresado

Gracias.

2012/4/30 mauricio rodriguez <rodriguez.mauricio55 en gmail.com>

> Puedes o bien indicar el campo especifico en el resultado o bien pedir
> solo el campo en el query.
>
> La última opción es la mejor por cuestiones de rendimiento.
>
> sql = """select *campo *from hospital_resgitro where id_usuario='42004790
> '"""
>
> o bien
>
> cursor.execute(sql)
> for elemento in cursor.fetchall():
>     print elemento*[numerodecampo]*
>
> 2012/4/30 fabio rojas <fabiorojas7 en gmail.com>
>
>>
>>>
>>
>> select * from hospital_resgitro where id_usuario='42004790 limit 1
>>
>>
>>
>> _______________________________________________
>> Python-es mailing list
>> Python-es en python.org
>> http://mail.python.org/mailman/listinfo/python-es
>> FAQ: http://python-es-faq.wikidot.com/
>>
>>
>
> _______________________________________________
> Python-es mailing list
> Python-es en python.org
> http://mail.python.org/mailman/listinfo/python-es
> FAQ: http://python-es-faq.wikidot.com/
>
>


-- 
 *Diego Alonso Uribe Gamez*
------------------------------

*Desarrollador web*

Twitter: @DiegoUG <http://www.twitter.com/DiegoUG>

Google+: http://gplus.to/diegoug
------------------------------
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20120430/5fe25ea9/attachment.html>


Más información sobre la lista de distribución Python-es