File: //lib/python3/dist-packages/boto/dynamodb2/__pycache__/table.cpython-312.pyc
�
ckF[�� � � � d dl Z d dlmZ d dlmZmZmZmZmZm Z m
Z
mZ d dlm
Z
d dlmZ d dlmZmZ d dlmZmZmZmZmZ d dlmZ G d � d
e� Z G d� de� Zy)
� N)�
exceptions)�HashKey�RangeKey�AllIndex�
KeysOnlyIndex�IncludeIndex�GlobalAllIndex�GlobalKeysOnlyIndex�GlobalIncludeIndex)�Item)�DynamoDBConnection)� ResultSet�BatchGetResultSet)�NonBooleanDynamizer� Dynamizer�FILTER_OPERATORS�QUERY_OPERATORS�STRING)�JSONResponseErrorc �n � e Zd ZdZdZ e eeee�� ee e
e�� �� Z d(d�Z
d� Ze d)d�� Zd*d �Zd
� Zd� Zd� Zd
� Zd+d�Zd� Zd� Zd� Zd� Zd� Zd,d�Zd� Zd� Zd� Zd-d�Z d*d�Z!d*d�Z"d+d�Z#d� Z$d� Z%e&fd�Z' d.d�Z( d/d �Z) d0d!�Z* d1d"�Z+ d2d#�Z, d2d$�Z-d,d%�Z.d,d&�Z/d'� Z0y)3�Tablea�
Interacts & models the behavior of a DynamoDB table.
The ``Table`` object represents a set (or rough categorization) of
records within DynamoDB. The important part is that all records within the
table, while largely-schema-free, share the same schema & are essentially
namespaced for use in your application. For example, you might have a
``users`` table or a ``forums`` table.
�d )�ALL� KEYS_ONLY�INCLUDE)�global_indexes�
local_indexesNc �� � || _ || _ ddd�| _ || _ || _ || _ | j �t
� | _ |�|| _ t � | _ y)a
Sets up a new in-memory ``Table``.
This is useful if the table already exists within DynamoDB & you simply
want to use it for additional interactions. The only required parameter
is the ``table_name``. However, under the hood, the object will call
``describe_table`` to determine the schema/indexes/throughput. You
can avoid this extra call by passing in ``schema`` & ``indexes``.
**IMPORTANT** - If you're creating a new ``Table`` for the first time,
you should use the ``Table.create`` method instead, as it will
persist the table structure to DynamoDB.
Requires a ``table_name`` parameter, which should be a simple string
of the name of the table.
Optionally accepts a ``schema`` parameter, which should be a list of
``BaseSchemaField`` subclasses representing the desired schema.
Optionally accepts a ``throughput`` parameter, which should be a
dictionary. If provided, it should specify a ``read`` & ``write`` key,
both of which should have an integer value associated with them.
Optionally accepts a ``indexes`` parameter, which should be a list of
``BaseIndexField`` subclasses representing the desired indexes.
Optionally accepts a ``global_indexes`` parameter, which should be a
list of ``GlobalBaseIndexField`` subclasses representing the desired
indexes.
Optionally accepts a ``connection`` parameter, which should be a
``DynamoDBConnection`` instance (or subclass). This is primarily useful
for specifying alternate connection parameters.
Example::
# The simple, it-already-exists case.
>>> conn = Table('users')
# The full, minimum-extra-calls case.
>>> from boto import dynamodb2
>>> users = Table('users', schema=[
... HashKey('username'),
... RangeKey('date_joined', data_type=NUMBER)
... ], throughput={
... 'read':20,
... 'write': 10,
... }, indexes=[
... KeysOnlyIndex('MostRecentlyJoined', parts=[
... HashKey('username')
... RangeKey('date_joined')
... ]),
... ], global_indexes=[
... GlobalAllIndex('UsersByZipcode', parts=[
... HashKey('zipcode'),
... RangeKey('username'),
... ],
... throughput={
... 'read':10,
... 'write':10,
... }),
... ], connection=dynamodb2.connect_to_region('us-west-2',
... aws_access_key_id='key',
... aws_secret_access_key='key',
... ))
� )�read�writeN) �
table_name�
connection�
throughput�schema�indexesr r
r �
_dynamizer)�selfr"