[Python-es] consulta SQL

Sergio Soto Núñez scots4ever en gmail.com
Sab Jun 19 19:32:19 CEST 2010


Si se puede. Eso no es cuestión de pySQL si no de Mysql:
http://dev.mysql.com/doc/refman/5.0/es/select.html
__________________________________________________________
Hay una fuerza motriz más poderosa que el vapor, la electricidad y la
energía atómica: la voluntad.
Albert Einstein (1879-1955)



2010/6/19 monoBOT <monobot.soft en gmail.com>

> otra preguntilla de pysql
>
> cuando creo la tabla le pongo a las columnas que sean TEXT pero no se si es
> posible de esta forma solicitarle un ORDER BY ... es posible? es que no me
> lo hace y no me gustaría cambiarlas a FLOAT porque me da errores al cargar
> los datos desde python.
>
>
> 2010/6/18 monoBOT <monobot.soft en gmail.com>
>
>> perdon ... a los 3!!!!!!!!!!!!!
>>
>> 2010/6/18 monoBOT <monobot.soft en gmail.com>
>>
>> muchas gracias a los 2!!!
>>>
>>>
>>> 2010/6/18 Antonio Beamud Montero <antonio.beamud en gmail.com>
>>>
>>> monoBOT escribió:
>>>>
>>>>> Hola ... como puedo obtener la cantidad de columnas de una tabla?
>>>>>
>>>>> hice lo siguiente de modo rudimentario pero seguramente existe una
>>>>> forma mucho mas directa ... alguna pista?
>>>>>
>>>>>
>>>>> orden = 'SELECT * FROM nombretabla WHERE id = 1' cursor.execute(orden)
>>>>>  for objeto in cursor:
>>>>>    valor = len(objeto)-1
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>
>>>> de http://www.python.org/dev/peps/pep-0249/:
>>>>
>>>> Cursor Objects should respond to the following methods and
>>>>   attributes:
>>>>
>>>>       .description                     This read-only attribute is a
>>>> sequence of 7-item
>>>>           sequences.
>>>>           Each of these sequences contains information describing
>>>>           one result column:
>>>>             (name,               type_code,               display_size,
>>>>              internal_size,               precision,
>>>> scale,               null_ok)
>>>>
>>>>           The first two items (name and type_code) are mandatory,
>>>>           the other five are optional and are set to None if no
>>>>           meaningful values can be provided.
>>>>
>>>>           This attribute will be None for operations that
>>>>           do not return rows or if the cursor has not had an
>>>>           operation invoked via the .execute*() method yet.
>>>>                      The type_code can be interpreted by comparing it to
>>>> the
>>>>
>>>>
>>>> Es decir, si haces len(cursor.description) te dice el total de columnas.
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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/
>
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20100619/30b2ac39/attachment.html>


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