added python functions to use SQL queries