Skip to main content

Flask-PynamoDB is an extension for integrating with PynamoDB

Project description

Flask-PynamoDB

codecov Code style: black PyPI Python

Flask-PynamoDB is an externsion for Flask that integrates with DynamoDB using the powerful PynamoDB library.

Flask-PynamoDB simplfies the configuration of PynamoDB for your application, as well as adds utilities for better integration with PynamoDB.

Installation

You can install & update the library using pip:

python -m pip install -U Flask-PynamoDB

or:

pip install -U Flask-PynamoDB

Quickstart

from uuid import uuid4
from typing import List

from flask import Flask, render_template
from flask_pynamodb import PynamoDB
from pynamodb.attributes import BooleanAttribute, UnicodeAttribute


class Config:
    DYNAMODB_HOST = "http://localhost:8000"
    DYNAMODB_AWS_ACCESS_KEY_ID = "test"
    DYNAMODB_AWS_SECRET_ACCESS_KEY = "test"
    DYNAMODB_READ_CAPACITY_UNITS = 10
    DYNAMODB_WRITE_CAPACITY_UNITS = 10


app = Flask(__name__)
app.config.from_object(Config)
db = PynamoDB(app)


class Todo(db.Model):
    class Meta:
        table_name = "todo"

    id = UnicodeAttribute(hash_key=True)
    name = UnicodeAttribute()
    description = UnicodeAttribute()
    done = BooleanAttribute(default=False)


@app.route("/")
def index() -> List[str]:
    return [todo.name for i in Todo.scan()]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-PynamoDB-0.0.2.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file Flask-PynamoDB-0.0.2.tar.gz.

File metadata

  • Download URL: Flask-PynamoDB-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2

File hashes

Hashes for Flask-PynamoDB-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6b6d20f2139768523e37dbe7b63ec0e10bc4f88eb78977de984ca279e246ea50
MD5 eca8aad423041fe56dee978e3cb82172
BLAKE2b-256 9ea7b65a7ce11a77909aa7f020b43b9563126a469e4430155efd77e0c20fe4f0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page