How to create Dictionary in python code with multiple email ids?

project
python
mysql

#1

Hi Everyone, Im using Python Mandrill API to send mass emails. The link to the code is here https://mandrillapp.com/api/docs/messages.python.html#method=send-template

What I have figured is that to send multiple emails I have to fetch email addresses and names from my database and create a python dictionary in the code like below:

'to': [{'email': 'recipient1@example.com', 'name': 'Recipient1', 'type': 'to'}, {'email': 'recipient2@example.com', 'name': 'Recipient2', 'type': 'to'}, {'email': 'recipient3@example.com', 'name': 'Recipient3', 'type': 'to'}]

This dictionary contains only 3 emails but I will have to create something similar for the 10000 email address I have in my MYSQL databases.

What I wanted to know was what's an easy way to create a similar dictionary with 10000 emails from the MYSQL database?

Thanks in advance


#2

Just as a sidebar: https://www.google.ca/search?q=mysql+in+python