pynamodb / PynamoDB

A pythonic interface to Amazon's DynamoDB
http://pynamodb.readthedocs.io
MIT License
2.44k stars 427 forks source link

Support tableprefix #487

Open trondhindenes opened 6 years ago

trondhindenes commented 6 years ago

Since DynamoDB tables are globally unique, it's a bit cumbersome to store the table name inside the model class. It would be awesome to be able to set a "table prefix" on the connection object or similar, so that the model classes themselves could be static and not require dynamic configuration injected. This would allow scenarios like dev/test inside the same aws account etc.

numberoverzero commented 6 years ago

I've also found a function (in addition to a prefix or template string) is very useful for automated testing, where I'd use a nonce to isolate integration tests:

nonce = lambda model: model.Meta.table_name + str(time.time())

I think this needs to be somewhere on the Connection object, looking through https://pynamodb.readthedocs.io/en/latest/low_level.html#creating-a-connection

m-melis commented 2 years ago

This would be so useful

ikonst commented 1 year ago

Were tables names globally unique in 2018? They certainly don't seem to be now:

Names should be meaningful and concise—for example, names such as Products, Books, and Authors are self-explanatory.