problem with appending to a list, possibly mysqldb related

John Purser jmpurser at gmail.com
Thu Aug 31 14:30:19 EDT 2006


On Thu, 31 Aug 2006 18:11:15 GMT
John Salerno <johnjsal at NOSPAMgmail.com> wrote:

> Here's the code:
> 
> class MyFrame(wx.Frame):
> 
>      def __init__(self):
>          wx.Frame.__init__(self, None, wx.ID_ANY)
>          panel = wx.Panel(self)
>          dbconn = self.connect_db()
>          dbconn.execute("select namefirst, namelast from master")
>          bb_players = []
> 
>          for x in dbconn.fetchall():
>              bb_players.append(' '.join(x))
> 
>          cb = PromptingComboBox(panel, 'Choose A Player', 
> choices=bb_players, style=wx.CB_SORT)
> 
>      def connect_db(self):
>          connection = MySQLdb.connect('localhost', 'john', '*******',
>                                       'bbdatabank')
>          return connection.cursor()
> 
> 
> The error seems to be in the for loop. I get this:
> 
> Traceback (most recent call last):
>    File "C:\Python24\myscripts\bbdata_access\bbdata.py", line 71, in 
> -toplevel-
>      app = MyApp(False)
>    File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", 
> line 7700, in __init__
>      self._BootstrapApp()
>    File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\_core.py", 
> line 7352, in _BootstrapApp
>      return _core_.PyApp__BootstrapApp(*args, **kwargs)
>    File "C:\Python24\myscripts\bbdata_access\bbdata.py", line 64, in
> OnInit frame = MyFrame()
>    File "C:\Python24\myscripts\bbdata_access\bbdata.py", line 15, in 
> __init__
>      name = ' '.join(x)
> TypeError: sequence item 0: expected string, NoneType found
>  >>>

John,

I'd say you had a record with a null value for the namefirst field.
The join method don't like that.  

John Purser


-- 
You are destined to become the commandant of the fighting men of the
department of transportation.



More information about the Python-list mailing list