in postgresql_metrics/postgres_queries.py [0:0]
def query(cursor, sql, params=None):
"""accepts a database connection or cursor"""
if type(cursor) == psycopg2._psycopg.connection:
cursor = cursor.cursor()
LOG.debug('QUERY "{}" {}', sql, params)
try:
if params:
cursor.execute(sql, params)
else:
cursor.execute(sql)
results = cursor.fetchall()
except Exception:
LOG.exception("failed calling the database")
results = []
LOG.debug('QUERY RESULT: {}', results)
return results