API Reference¶
-
class
flask_pynamodb.
PynamoDB
(app: flask.app.Flask = None)¶ The main class for initializing and managing PynamoDB integration to one / multiple Flask applications.
-
app
¶ The Flask application that uses DynamoDB. For using more that one app, you should use
init_app
method. Please note the model class supports a configuration of one app only.- Type
Flask
-
class
Model
(hash_key=None, range_key=None, _user_instantiated=True, **attributes)¶ The base model, with the application’s config. The model is backed by a table inside DynamoDB.
-
exception
DoesNotExist
(msg=None, cause=None)¶
-
Meta
¶ alias of
pynamodb.models.DefaultMeta
-
classmethod
first_or_404
(message: str = '') → flask_pynamodb.model.Model¶ Gets the first item from the table.
- Parameters
message (str) – Custom message for the 404 Not Found error.
- Returns
An instance of the model for the desired item.
- Return type
- Raises
HTTPException – if the item does not exist, 404 Not Found error will be raised.
-
classmethod
get_or_404
(*args, **kwargs) → flask_pynamodb.model.Model¶ Gets an item and raises a 404 Not Found error if the item does not exist.
- Parameters
hash_key (str) – The hash key of the desired item.
range_key (
str
, optional) – The range key of the desired item, only used when appropriate.consistent_read (bool) –
attributes_to_get (
Sequence
, optional) –message – Custom message for the 404 Not Found error.
- Returns
An instance of the model for the desired item.
- Return type
- Raises
HTTPException – if the item does not exist, 404 Not Found error will be raised.
-
exception
-
property
connection
¶ Base connection object, for accessing DynamoDB.
- Type
str
-
init_app
(app: flask.app.Flask)¶ Initializes a Flask application for using the integration. Currently, the model class supports a single app configuration only. Therefore, if there are multiple app configurations for this integration,
the configuration will be overriden.
- Parameters
app (Flask) – The flask application to initialize.
-