In order to handle a growing database table, we are sharding on table name. So we could have database tables that are named like this:
table_md5one
table_md5
In Augmenting the Base you find a way of using a custom Base
class that can, for example, calculate the __tablename__
attribure dynamically:
class Base(object):
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
The only problem here is that I don't know where your hash comes from, but this should give a good starting point.
If you require this algorithm not for all your tables but only for one you could just use the declared_attr
on the table you are interested in sharding.