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.

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()

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.