Table¶
The module to interact with DynamoDB.
- lorien.database.table.check_table(table_name: str, table_arn: str, **db_kwargs) bool ¶
Check if the DynamoDB table name and ARN match the one this worker can access to.
- Parameters
table_name (str) -- Table name.
table_arn (str) -- Table Amazon Resource Name.
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- Returns
success -- False if the table and ARN does not exist in the DynamoDB.
- Return type
bool
- lorien.database.table.create_table(table_name: str, **db_kwargs) str ¶
Create an empty table in the DynamoDB if the table does not exist.
- Parameters
table_name (str) -- The table name.
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- Returns
arn -- The table ARN (Amazon Resource Name).
- Return type
str
- lorien.database.table.delete_table(table_name: str, **db_kwargs) None ¶
Delete the given table in the database.
- Parameters
table_name (str) -- The table name in string.
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- lorien.database.table.list_tables(**db_kwargs) List[str] ¶
List all table names in the database.
- Parameters
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- Returns
tables -- A list of sorted table names.
- Return type
List[str]
- lorien.database.table.scan_table(table_name: str, limit: Optional[int] = None, **db_kwargs) Generator ¶
Scan a DynamoDB table for all items. Note that DynamoDB only transfers at most 1 MB data per query, so you may need to invoke this generator several times to get the entire table.
- Parameters
table_name (str) -- The target table name to be scanned.
**db_kwargs -- The kwargs of boto3 client. For example, use "endpoint_url=http://localhost:8000" for local DynamoDB.
- Returns
gen -- A generator that yields a scan query response (at most 1 MB).
- Return type
Generator