min-ops / cruddy Goto Github PK
View Code? Open in Web Editor NEWA simple CRUD wrapper around Amazon DynamoDB
License: Apache License 2.0
A simple CRUD wrapper around Amazon DynamoDB
License: Apache License 2.0
I just did a
./cruddy search my_id=72538
and received the following stacktrace:
error
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/Current/bin/cruddy", line 9, in <module>
load_entry_point('cruddy==0.9.0', 'console_scripts', 'cruddy')()
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/cruddy/scripts/cli.py", line 159, in search
handler.invoke(data)
File "/usr/local/lib/python2.7/site-packages/cruddy/scripts/cli.py", line 70, in invoke
self._invoke_lambda(payload)
File "/usr/local/lib/python2.7/site-packages/cruddy/scripts/cli.py", line 56, in _invoke_lambda
click.echo(click.style(crud_response['error_type'], fg='red'))
File "/usr/local/lib/python2.7/site-packages/click/termui.py", line 393, in style
return ''.join(bits)
TypeError: sequence item 1: expected string, NoneType found
It would be nice to have a CLI command that would generate a JSON object with the required attribute already present. That would allow me to then edit the file and give it to create
.
Kinda like the CLI skeleton from the AWS CLI.
It looks like the LambdaClient is missing the update
method...doh!
The operation is now called search
It would be nice if when calling increment
using the cruddy CLI that it returned the new number. Currently it just returns null
In boto3, I can do a consistent read with the following
table.get_item(
Key={
'id': self._my_id
},
ConsistentRead=True
)
Given the current _get()
function, I am not sure how I could do that, resulting in all reads being eventually consistent.
Not the best experience:
line 49, in load_xyz response = self._xyz_crud.get(self.id)
File "/var/task/cruddy/__init__.py",
line 210, in get item = response.raw_response['Item'] KeyError: 'Item'
I think returning a response would be better
Sometimes, it is useful to get
an item from a cruddy handler, make some modifications and then update
it. Same with list
: iterate through and update
specific items.
If there are any encrypted fields, the data from those methods above is not suitable to pass to update
as it would result in the encrypted fields being double-encrypted. A get
must be called with decrypt=True
, and list
has no such option.
One idea is to make it possible to update
an item without encrypting fields. Perhaps
update(item, encrypt=False)
where this stores all fields in item verbatim in DynamoDB.
Currently, if you call increment_counter
on an id
that doesn't existing in the table yet, the response is:
{
"status": "error",
"error_message": "The provided expression refers to an attribute that does not exist in the item",
"error_code": "ValidationException",
"error_type": null,
"raw_response": null,
"data": null,
"metadata": null
}
That means you must first call create
and give the item a starting number before you can subsequently call increment_counter
.
I am thinking it would be nice to handle that inside cruddy. When the above happens, make a subsequent call to create
and set the counter_name
to whatever the increment is as the initial number.
Thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.