[Python-es] Seleccionar un solo elemento SQL

mauricio rodriguez rodriguez.mauricio55 en gmail.com
Lun Abr 30 21:12:17 CEST 2012


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/
>
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20120430/71384423/attachment.html>


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