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 <[email protected]> > perdon ... a los 3!!!!!!!!!!!!! > > 2010/6/18 monoBOT <[email protected]> > > muchas gracias a los 2!!! >> >> >> 2010/6/18 Antonio Beamud Montero <[email protected]> >> >> 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 >>> [email protected] >>> http://mail.python.org/mailman/listinfo/python-es >>> FAQ: http://python-es-faq.wikidot.com/ >>> >> >> >
_______________________________________________ Python-es mailing list [email protected] http://mail.python.org/mailman/listinfo/python-es FAQ: http://python-es-faq.wikidot.com/
