All python codes
This code can be used to run a query in any database(I have used amazon redshift but this should work for any database) and then create a file and send it as an attachment to multiple email ids.
You would need an app password for the email account as regular login passwords don't work here.
Replace apppassword in code with actual app password.