Skip to content

This package can pull random public tweets from Twitter (tweets-streaming.py) or generates simulated tweets (tweets-simulated.py). The result will be stored into a DynamoDB table.

License

Notifications You must be signed in to change notification settings

ajorg-aws/aws-blog-dynamodb-analysis

 
 

Repository files navigation

aws-blog-dynamodb-analysis

This package can pull random public tweets from Twitter (tweets-streaming.py) or generates simulated tweets (tweets-simulated.py). The result will be stored into a DynamoDB table.

tweets-streaming.py

This script pulls random tweets from the Twitter API and stores them in Amazon DynamoDB. There are two modules needed to execute the script:

A Twitter account is needed to access Twitter API. Go to https://www.twitter.com/ and sign up for a free account, if you don't already have one. Once your account is up, go to https://apps.twitter.com/ and on the main landing page, click the grey "Create New App" button. After you give it a name, you can go to the "Keys and Access Tokens" to get your credentials to use the Twitter API. You will need to generate Customer Tokens/Secret and Access Token/Secret. All four keys will be used to authenticate your request.

In the script, update the following lines with the real security credentials:

# Twitter security credentials 
ACCESS_TOKEN    = "...01234..."
ACCESS_SECRET   = "...i7RkW..."
CONSUMER_KEY    = "...be4Ma..."
CONSUMER_SECRET = "...btcar..."

This section can be customized according to your preference. Use your own table name and TTL value as desired:

# Global variables.
dynamodb_table     = "TwitterAnalysis"
expires_after_days = 30

tweets-simulated.py

This script generates simulated tweets and stores them in Amazon DynamoDB. There are three modules needed to execute the script:

In the script, update the following lines with the real security credentials:

# Twitter security credentials 
ACCESS_TOKEN    = "...01234..."
ACCESS_SECRET   = "...i7RkW..."
CONSUMER_KEY    = "...be4Ma..."
CONSUMER_SECRET = "...btcar..."

This section can be customized according to your preference. Use your own table name and TTL value as desired:

# Global variables
dynamodb_table  = "TwitterAnalysis"
provisioned_wcu = 1

License Summary

This sample code is made available under the MIT-0 license. See the LICENSE file.

About

This package can pull random public tweets from Twitter (tweets-streaming.py) or generates simulated tweets (tweets-simulated.py). The result will be stored into a DynamoDB table.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%