def one_val_raw_sql(raw_sql, values=[]):
  from django.db import connection, transaction
  cursor = connection.cursor()

  cursor.execute(raw_sql, values)
  return cursor.fetchone()[0]
for a simple aggregate
dataset/ETHPy150Open benadida/helios-server/helios/utils.py/one_val_raw_sql