0

When I run this code:

sql = "SELECT Name FROM nameDatabase"
self.cursor.execute(sql)
list=self.cursor.fetchall()
print list

I get:

>>> [(u'Joe',), (u'Katie',), (u'Bob',), (u'Ian',)]

However, if I try to make a SingleChoiceDialog with wxpython it does not like that list.

Is there any way to get those values in a so it would look like:

>>>

I appreciate any help or suggestions.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by jice
0

I figured it out:

nameList=[]
index=0
sql = "SELECT Name FROM nameDatabase"
self.cursor.execute(sql)
all=self.cursor.fetchall()
while index<len(all):
            nameList.append(all[index][0])
            index=index+1
self.connection.commit()
self.connection.close()
0

You can do more efficient :

sql = "SELECT Name FROM nameDatabase"
self.cursor.execute(sql)
list=[element[0] for element in self.cursor.fetchall()]
print list
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.