Skip to main content

Boto SQS integration for Flask

Project description

Initialize

from flask_boto_sqs import FlaskBotoSQS

sqs = FlaskBotoSQS(app)

or:

sqs = FlaskBotoSQS()
sqs.init_app(app)

Configuration

Put kwargs for FlaskBotoSQS to ‘FLASK_BOTO_SQS’ in your Flask configuration.

app.config['FLASK_BOTO_SQS'] = {
    'region': 'ap-northeast-1',
    'aws_access_key_id': 'YOUR_AWS_ACCESS_KEY_ID',
    'aws_secret_access_key': 'YOUR_AWS_SECRET_ACCESS_KEY'
}

Usage

# http://docs.pythonboto.org/en/latest/ref/sqs.html
# http://docs.pythonboto.org/en/latest/sqs_tut.html

q = sqs.conn.get_queue('your-queue-name')

# write
from boto.sqs.message import Message
m = Message()
m.set_body('What a lovely day!')
q.write(m)

# read
m = q.read()
res = m.get_body()
print res
q.delete_message(m)

Project details


Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page