If you want to get a file from an S3 Bucket and then put it in a Python string, try the examples below.
boto3, the AWS SDK for Python, offers two distinct methods for accessing files or objects in Amazon S3:
client method and the
Option 1 uses the
boto3.client('s3') method, while options 2 and 3 use the
All 3 options do the exact same thing so get the one that you feel comfortable with or the one that will fit your use case.
Continue reading How to read a file in S3 and store it in a String using Python and boto3
If you want to get a JSON file from an S3 Bucket and load it into a Python Dictionary then you can use the example codes below.
There are 4 scenarios for the examples scripts below.
- Basic JSON file from S3 to Python Dictionary
- With Try/Except block
- With datetime, date, and time conversions
- Running the code in a Lambda Function
AWS boto3 provides 2 ways to access S3 files, the
boto3.resource('s3'). For each of the example scenarios above, a code will be provided for the two methods.
Related: Writing a Dictionary to JSON file in S3 using boto3 and Python
Since both methods will function the same, you can choose whichever method you like.
Continue reading How to read a JSON file in S3 and store it in a Dictionary using boto3 and Python
My favorite Python connector for MySQL or MariaDB is MySQLdb, the problem with this connector is that it is complicated to install on Windows!
I am creating this article for those who want to install MySQLdb for Python 3 for Windows. Especially me, since each time I am doing a Python project that needs to connect to MariaDB or MySQL I always look on how to install MySQLdb.
If you are interested why I prefer MySQLdb compared to other MySQL connectors you may want to read the comparison of MySQL-connector and MySQLdb from Charles Nagy.
Problems with installing MySQLdb on Windows
You can actually install MySQLdb using pip. See pypi documentation here.
pip install MySQL-python
Unfortunately, the pypi documentation is already out of date with the latest release was on Jan 3, 2014. Continue reading Installing MySQLdb for Python 3 in Windows