add sql extraction code