CreateTable¶
When given a CreateTable
, the connection will return a CreateTableResponse
:
>>> r = connection(
... CreateTable(table)
... .hash_key("h", STRING)
... .provisioned_throughput(1, 1)
... )
>>> r
<LowVoltage.actions.create_table.CreateTableResponse ...>
>>> r.table_description.table_status
u'CREATING'
Note that you can use the wait_for_table_activation()
compound to poll the table status until it’s usable. See Actions vs. compounds in the user guide.
-
class
CreateTableResponse
¶ The CreateTable response.
-
table_description
¶ The description of the table you just created.
Type: None
orTableDescription
-
-
class
CreateTable
(table_name=None)¶ The CreateTable request.
Passing
table_name
to the constructor is like callingtable_name()
on the new instance.-
table_name
(table_name)¶ Set TableName. Mandatory, can also be set in the constructor.
See
range_key()
an example.
-
hash_key
(name, typ=None)¶ Set the hash key in KeySchema for the table or the active index. If you provide a second argument,
attribute_definition()
will be called as well.See
range_key()
an example.
-
range_key
(name, typ=None)¶ Set the range key in KeySchema for the table or the active index. If you provide a second argument,
attribute_definition()
will be called as well.>>> connection( ... CreateTable() ... .table_name(table2) ... .hash_key("h", STRING) ... .range_key("r") ... .provisioned_throughput(1, 1) ... .attribute_definition("r", NUMBER) ... ) <LowVoltage.actions.create_table.CreateTableResponse ...>
-
attribute_definition
(name, typ)¶ Set the type of an attribute in AttributeDefinitions. Key attribute must be typed. See
attribute_types
for constants to be passed to this method.See
range_key()
for an example.
-
provisioned_throughput
(read_capacity_units, write_capacity_units)¶ Set the read and write provisioned throughput for the table or the active index.
See
range_key()
,global_secondary_index()
orlocal_secondary_index()
for examples.
-
global_secondary_index
(name)¶ Add a GSI. This method sets the active index: methods like
hash_key()
will apply to the index.>>> connection( ... CreateTable(table3) ... .hash_key("h", STRING) ... .provisioned_throughput(1, 1) ... .global_secondary_index("gsi") ... .hash_key("a", BINARY) ... .range_key("b", NUMBER) ... .provisioned_throughput(1, 1) ... .project_all() ... ) <LowVoltage.actions.create_table.CreateTableResponse ...>
-
local_secondary_index
(name)¶ Add a LSI. This method sets the active index: methods like
hash_key()
will apply to the index.>>> connection( ... CreateTable(table4) ... .hash_key("h", STRING) ... .range_key("r", NUMBER) ... .provisioned_throughput(1, 1) ... .local_secondary_index("lsi") ... .hash_key("h") ... .range_key("a", NUMBER) ... .provisioned_throughput(1, 1) ... .project("x", "y") ... ) <LowVoltage.actions.create_table.CreateTableResponse ...>
-
table
()¶ Reset the active index: methods like
hash_key()
will apply to the table.
-
project_all
()¶ Set ProjectionType to ALL for the active index.
Raise: BuilderError
if called when no index is active.See
global_secondary_index()
for an example.
-
project_keys_only
()¶ Set ProjectionType to KEYS_ONLY for the active index.
Raise: BuilderError
if called when no index is active.
-
project
(*attrs)¶ Note that this function is variadic. See Variadic functions.
Set ProjectionType to INCLUDE for the active index and add names to NonKeyAttributes.
Raise: BuilderError
if called when no index is active.See
local_secondary_index()
for an example.
-