Saturday, 7 September 2013

Python sqlite3 NoneType error

Python sqlite3 NoneType error

We're working on a text-based game (MUD) and have hit this roadblock.
The code:
class RoomMove():
def __init__(self):
self.room = 1
self.name = 'Lorinth'
self.moveRooms()
self.updateRoom()
[extra code doesn't matter]
def updateRoom(self):
global c
room = str(self.room)
while room > 0:
c.execute("""SELECT * FROM RoomPlayers where ID=?""", room)
spaceCheck = c.fetchone()
counter = 1
if spaceCheck[counter] not in ('', None):
counter += 1
else:
room = self.room
name = self.name
c.execute("""UPDATE RoomPlayers SET '1'=? WHERE ID=?""",
(name, room))
conn.commit()
it throws back this error:
if spaceCheck[counter] not in ('', None):
TypeError: 'NoneType' object has no attribute '__getitem__'
Any ideas?
Thanks!

No comments:

Post a Comment