title: Easier way to read sqlite3 row into object?
body: <p>In Python, I'm reading rows from sqlite3 into an object that's a simple data structure.  At the moment of assignment, I have to assign the row to a series of variables.  Is there a way to do this in a simpler manner?</p>
  
  <p>I've included some sample code below that hopefully illustrates my problem.</p>
  
  <pre><code>import sqlite3
  
  class studentDef(object):
      def __init__(self):
          self.firstName = 'x'
          self.lastName  = 'x'
          self.id        = 'x'
          self.address1  = 'x'
          self.address2  = 'x'
          self.city      = 'x'
          self.state     = 'x'
          self.zip       = 'x'
          self.status    = 0
  
  def main():
      mystudent = studentDef()
      db        = sqlite3.connect('students.sqlite3')
      cursor    = db.cursor()
      selectTxt = "select * from students where status = 1"
      cursor.execute(selectTxt)
      rows = cursor.fetchall()
      for index in range(0,len(rows)):
          mystudent.firstName, mystudent.lastName, mystudent.id, mystudent.address1, \
              mystudent.address2, mystudent.city, mystudent.state, mystudent.zip, \
              mystudent.status = row[index]
          processStudent(mystudent)
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>My current code is reading in 50+ columns and the assignment statement is getting a bit hairy!  As I'm still developing, I'm constantly messing with the assignment statement while adding, removing, or modifying columns.</p>
  
  <p>Is there an easier way to do something like:</p>
  
  <pre><code>mystudent = row[index]
  </code></pre>
  
  <p>My other problem is that I'm doing this in about 5 other programs.  So every time I change the database layout, I'm spending a lot of time updating all of my code.</p>