################################################################################
# Select SQLite data into a Python list of dictionaries
################################################################################
import sqlite3

conn  = sqlite3.connect('/home/sultans/data/sqlite/sqlite.db')      #server database
#conn = sqlite3.connect('/sqlite/sqlite.db')                        #local database 

conn.row_factory = sqlite3.Row		#return a dictionary (with col names/values)

curs = conn.cursor( )

sql = """
      SELECT * FROM student
"""
curs.execute(sql)

result = curs.fetchall( )                       #get the query result

list = [ ]                                      #create an empty list
for row in result :                             #for each row in the result
      dict = { }                                #create an empty dictionary
      for colname in row.keys( ):               #for each column name in the row
            value = row[colname]                #get the column value
            if value == None: value = ""
            dict[colname] = value               #add the column name & value to dictionary
      list.append(dict)                         #add dictionary to the list

print(list)

curs.close()
conn.close()