I'm learning to use python with the database mysql. I'm writing a
widget in pygtk that should show the results of a sql query. For example
with SELECT * FROM a, I use this code
count = 0
a = db.cursor.description
for tuple in a:
print tuple[0][0]
count = count + 1
... to know how many columns are in the result, and then, what I have to
do is to create a liststore with count columns. The method to create
a ListStore is: liststore = gtk.ListStore(str, str, str, ...[number of
columns]). I was wondering how to create the liststore with the proper
number of columns, if there would a way to do something like this with
python:
# to store the number of columns that will be needed
count = 0
a = db.cursor.description
for tuple in a:
print tuple[0][0]
count = count + 1
# this is the string with the method to execute
method_string = gtk.ListStore(
for var in range(count):
method_string = function_string + str,
function_string = function_string + )
# is there something like this execute_function?
list_store = execute_function(method_string)
Thank you very much for your advices.
__
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor