try/except for None returned from sql query