def _create_table(client: BaseClient, database: str, table_name: str, mem_ttl: int, mag_ttl: int) -> None: try: client.create_table(DatabaseName=database, TableName=table_name, RetentionProperties={ 'MemoryStoreRetentionPeriodInHours': mem_ttl, 'MagneticStoreRetentionPeriodInDays': mag_ttl }) log.info( "Table [%s] successfully created (memory ttl: %sh, magnetic ttl: %sd.", table_name, mem_ttl, mag_ttl) except client.exceptions.ConflictException: # Table exists on database [{database}]. Skipping table creation" log.debug("Table [%s] exists. Skipping database creation.", table_name)
def create_table(cls, client: BaseClient, table_name: str) -> None: """Create the table for this KeyStore.""" try: client.create_table( TableName=table_name, KeySchema=[ { "AttributeName": "key_id", "KeyType": "HASH" }, ], AttributeDefinitions=[ { "AttributeName": "key_id", "AttributeType": "S" }, ], BillingMode="PAY_PER_REQUEST", ) except ClientError as exc: raise Exception("Could not create table", exc)