I need to apply more than one query to my SQL database. Every time I need to fetch all to get the result but I feel it's boring and not smart.
Is there any gentle way to shore the code and apply the following?
cursor = mydb.cursor()
updated_query = cursor.execute(
'select count(*) from event where update_count > 0 and date > now() - interval 24 hour')
result = cursor.fetchall()
for x in result:
print('Updated records in the last 24 hours:', x[0])
deleted_query = cursor.execute(
'select count(*) from event where deleted > 0 and date > now() - interval 24 hour')
result = cursor.fetchall()
for x in result:
print('Deleted records in the last 24 hours:', x[0])
total_last_24_hours = cursor.execute(
'select count(*) from event where date > now() - interval 24 hour')
result = cursor.fetchall()
for x in result:
print('Total records in the last 24 hours:', x[0])
total_events = cursor.execute('select count(*) from event')
result = cursor.fetchall()
for x in result:
print('Total records:', x[0])