as_pandas fails when the resultset has 0 rows.

We can switch to using pd.DataFrame.from_records which supports creating dataframes from a list of tuples.

This also avoids needing to construct temporary dictionaries for every row, speeding up dataframe creation by about a factor 3