We can’t write your program for you. I wonder if this can help get you started?
http://stackoverflow.com/questions/2279706/select-random-row-from-an-sqlite-table
You could always load in all the records into a table then shuffle the table too.
Rob