Skip to content

arnulfojr/sanic-persistance-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanic using Persistence layer

Spoiler alert!

NoSQL usage with PynamoDB (an ORM-like for DynamoDB) is only supported with sync (i.e. Flask, Sanic is async) code.

There's no migrations for DynamoDB but making simple migrations can be easily done.

Peewee offers more async support than SQLAlchemy's ORM.

DynamoDB

Use of aiobotocore and aioboto3.

Migrations in NoSQL

Migrations in NoSQL are kind of missleading, but the requirements are pretty much basic when talking DynamoDB.

To ensure tables are present, as DynamoDB requires it, a simple ensure_table method is required to create a table and avoiding to recreate and fail. In the same sense, downgrading would be deleting the table delete_table method is therefore present.

Updating indexes can be done in that sense, first ensuring the base table exists then updating the table indexes using botocore's API.

Therefore a simple upgrade and downgrade method is required.

For the full research, please refer to:

ORM

Usage of ORM through peewee.

Schema Validation