Skip to content

Instantly share code, notes, and snippets.

@kenvontucky
Created March 2, 2020 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenvontucky/1100684a10ed344b91f1ccf00d41a1f8 to your computer and use it in GitHub Desktop.
Save kenvontucky/1100684a10ed344b91f1ccf00d41a1f8 to your computer and use it in GitHub Desktop.
from dynamo.base import DynamoBase
from samples.domain.schema import TABLE_NAME, DOMAIN, URL
class DynamoDomain(DynamoBase):
def get_params(self, key):
params = {
'TableName': TABLE_NAME,
'Key': {
URL: {"S": key}
}
}
return params
def put_params(self, key, data):
params = {
'TableName': TABLE_NAME,
'Item': {
URL: {"S": key},
}
}
params['Item'].update(data)
return params
def remove_params(self, key):
params = {
'TableName': TABLE_NAME,
'Key': {
URL: {"S": key}
}
}
return params
def set_value(self, key, value):
params = {
DOMAIN: {'S': value}
}
self.put(key, params)
def get_domain(self, key):
data = self.get(key)
return data['Item'][URL]['S']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment