sdb

boto.sdb

boto.sdb.connect_to_region(region_name, **kw_params)

Given a valid region name, return a boto.sdb.connection.SDBConnection.

Type:str
Parameters:region_name – The name of the region to connect to.
Return type:boto.sdb.connection.SDBConnection or None
Returns:A connection to the given region, or None if an invalid region name is given
boto.sdb.get_region(region_name, **kw_params)

Find and return a boto.sdb.regioninfo.RegionInfo object given a region name.

Type:str
Param:The name of the region.
Return type:boto.sdb.regioninfo.RegionInfo
Returns:The RegionInfo object for the given region or None if an invalid region name is provided.
boto.sdb.regions()

Get all available regions for the SDB service.

Return type:list
Returns:A list of boto.sdb.regioninfo.RegionInfo instances

boto.sdb.connection

class boto.sdb.connection.ItemThread(name, domain_name, item_names)

A threaded Item retriever utility class. Retrieved Item objects are stored in the items instance variable after run() is called.

Tip

The item retrieval will not start until the run() method is called.

Parameters:
  • name (str) – A thread name. Used for identification.
  • domain_name (str) – The name of a SimpleDB Domain
  • item_names (string or list of strings) – The name(s) of the items to retrieve from the specified Domain.
Variables:

items (list) – A list of items retrieved. Starts as empty list.

run()

Start the threaded retrieval of items. Populates the items list with Item objects.

class boto.sdb.connection.SDBConnection(aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', converter=None)

This class serves as a gateway to your SimpleDB region (defaults to us-east-1). Methods within allow access to SimpleDB Domain objects and their associated Item objects.

Tip

While you may instantiate this class directly, it may be easier to go through boto.connect_sdb().

For any keywords that aren’t documented, refer to the parent class, boto.connection.AWSAuthConnection. You can avoid having to worry about these keyword arguments by instantiating these objects via boto.connect_sdb().

Parameters:region (boto.sdb.regioninfo.SDBRegionInfo) – Explicitly specify a region. Defaults to us-east-1 if not specified.
APIVersion = '2009-04-15'
DefaultRegionEndpoint = 'sdb.amazonaws.com'
DefaultRegionName = 'us-east-1'
ResponseError

alias of SDBResponseError

batch_delete_attributes(domain_or_name, items)

Delete multiple items in a domain.

Parameters:
  • domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
  • items (dict or dict-like object) –

    A dictionary-like object. The keys of the dictionary are the item names and the values are either:

    • dictionaries of attribute names/values, exactly the same as the attribute_names parameter of the scalar put_attributes call. The attribute name/value pairs will only be deleted if they match the name/value pairs passed in.
    • None which means that all attributes associated with the item should be deleted.
Returns:

True if successful

batch_put_attributes(domain_or_name, items, replace=True)

Store attributes for multiple items in a domain.

Parameters:
  • domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
  • items (dict or dict-like object) – A dictionary-like object. The keys of the dictionary are the item names and the values are themselves dictionaries of attribute names/values, exactly the same as the attribute_names parameter of the scalar put_attributes call.
  • replace (bool) – Whether the attribute values passed in will replace existing values or will be added as addition values. Defaults to True.
Return type:

bool

Returns:

True if successful

create_domain(domain_name)

Create a SimpleDB domain.

Parameters:domain_name (string) – The name of the new domain
Return type:boto.sdb.domain.Domain object
Returns:The newly created domain
delete_attributes(domain_or_name, item_name, attr_names=None, expected_value=None)

Delete attributes from a given item in a domain.

Parameters:
  • domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
  • item_name (string) – The name of the item whose attributes are being deleted.
  • attributes (dict, list or boto.sdb.item.Item) – Either a list containing attribute names which will cause all values associated with that attribute name to be deleted or a dict or Item containing the attribute names and keys and list of values to delete as the value. If no value is supplied, all attribute name/values for the item will be deleted.
  • expected_value (list) –

    If supplied, this is a list or tuple consisting of a single attribute name and expected value. The list can be of the form:

    • [‘name’, ‘value’]

    In which case the call will first verify that the attribute “name” of this item has a value of “value”. If it does, the delete will proceed, otherwise a ConditionalCheckFailed error will be returned. The list can also be of the form:

    • [‘name’, True|False]

    which will simply check for the existence (True) or non-existence (False) of the attribute.

Return type:

bool

Returns:

True if successful

delete_domain(domain_or_name)

Delete a SimpleDB domain.

Caution

This will delete the domain and all items within the domain.

Parameters:domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
Return type:bool
Returns:True if successful
domain_metadata(domain_or_name)

Get the Metadata for a SimpleDB domain.

Parameters:domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
Return type:boto.sdb.domain.DomainMetaData object
Returns:The newly created domain metadata object
get_all_domains(max_domains=None, next_token=None)

Returns a boto.resultset.ResultSet containing all boto.sdb.domain.Domain objects associated with this connection’s Access Key ID.

Parameters:
  • max_domains (int) – Limit the returned ResultSet to the specified number of members.
  • next_token (str) – A token string that was returned in an earlier call to this method as the next_token attribute on the returned ResultSet object. This attribute is set if there are more than Domains than the value specified in the max_domains keyword. Pass the next_token value from you earlier query in this keyword to get the next ‘page’ of domains.
get_attributes(domain_or_name, item_name, attribute_names=None, consistent_read=False, item=None)

Retrieve attributes for a given item in a domain.

Parameters:
  • domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
  • item_name (string) – The name of the item whose attributes are being retrieved.
  • attribute_names (string or list of strings) – An attribute name or list of attribute names. This parameter is optional. If not supplied, all attributes will be retrieved for the item.
  • consistent_read (bool) – When set to true, ensures that the most recent data is returned.
  • item (boto.sdb.item.Item) – Instead of instantiating a new Item object, you may specify one to update.
Return type:

boto.sdb.item.Item

Returns:

An Item with the requested attribute name/values set on it

get_domain(domain_name, validate=True)

Retrieves a boto.sdb.domain.Domain object whose name matches domain_name.

Parameters:
  • domain_name (str) – The name of the domain to retrieve
  • validate (bool) – When True, check to see if the domain actually exists. If False, blindly return a Domain object with the specified name set.
Raises:

boto.exception.SDBResponseError if validate is True and no match could be found.

Return type:

boto.sdb.domain.Domain

Returns:

The requested domain

get_domain_and_name(domain_or_name)

Given a str or boto.sdb.domain.Domain, return a tuple with the following members (in order):

Parameters:domain_or_name (str or boto.sdb.domain.Domain) – The domain or domain name to get the domain and name for.
Raises:boto.exception.SDBResponseError when an invalid domain name is specified.
Return type:tuple
Returns:A tuple with contents outlined as per above.
get_usage()

Returns the BoxUsage (in USD) accumulated on this specific SDBConnection instance.

Tip

This can be out of date, and should only be treated as a rough estimate. Also note that this estimate only applies to the requests made on this specific connection instance. It is by no means an account-wide estimate.

Return type:float
Returns:The accumulated BoxUsage of all requests made on the connection.
lookup(domain_name, validate=True)

Lookup an existing SimpleDB domain. This differs from get_domain() in that None is returned if validate is True and no match was found (instead of raising an exception).

Parameters:
  • domain_name (str) – The name of the domain to retrieve
  • validate (bool) – If True, a None value will be returned if the specified domain can’t be found. If False, a Domain object will be dumbly returned, regardless of whether it actually exists.
Return type:

boto.sdb.domain.Domain object or None

Returns:

The Domain object or None if the domain does not exist.

print_usage()

Print the BoxUsage and approximate costs of all requests made on this specific SDBConnection instance.

Tip

This can be out of date, and should only be treated as a rough estimate. Also note that this estimate only applies to the requests made on this specific connection instance. It is by no means an account-wide estimate.

put_attributes(domain_or_name, item_name, attributes, replace=True, expected_value=None)

Store attributes for a given item in a domain.

Parameters:
  • domain_or_name (string or boto.sdb.domain.Domain object.) – Either the name of a domain or a Domain object
  • item_name (string) – The name of the item whose attributes are being stored.
  • attribute_names (dict or dict-like object) – The name/value pairs to store as attributes
  • expected_value (list) –

    If supplied, this is a list or tuple consisting of a single attribute name and expected value. The list can be of the form:

    • [‘name’, ‘value’]

    In which case the call will first verify that the attribute “name” of this item has a value of “value”. If it does, the delete will proceed, otherwise a ConditionalCheckFailed error will be returned. The list can also be of the form:

    • [‘name’, True|False]

    which will simply check for the existence (True) or non-existence (False) of the attribute.

  • replace (bool) – Whether the attribute values passed in will replace existing values or will be added as addition values. Defaults to True.
Return type:

bool

Returns:

True if successful

select(domain_or_name, query='', next_token=None, consistent_read=False)

Returns a set of Attributes for item names within domain_name that match the query. The query must be expressed in using the SELECT style syntax rather than the original SimpleDB query language. Even though the select request does not require a domain object, a domain object must be passed into this method so the Item objects returned can point to the appropriate domain.

Parameters:
  • domain_or_name (string or boto.sdb.domain.Domain object) – Either the name of a domain or a Domain object
  • query (string) – The SimpleDB query to be performed.
  • consistent_read (bool) – When set to true, ensures that the most recent data is returned.
Return type:

ResultSet

Returns:

An iterator containing the results.

set_item_cls(cls)

While the default item class is boto.sdb.item.Item, this default may be overridden. Use this method to change a connection’s item class.

Parameters:cls (object) – The new class to set as this connection’s item class. See the default item class for inspiration as to what your replacement should/could look like.

boto.sdb.db

boto.sdb.db.blob

class boto.sdb.db.blob.Blob(value=None, file=None, id=None)

Blob object

file
next()
read()
readline()
size

boto.sdb.db.key

class boto.sdb.db.key.Key(encoded=None, obj=None)
app()
classmethod from_path(*args, **kwds)
has_id_or_name()
id()
id_or_name()
kind()
name()
parent()

boto.sdb.db.manager

boto.sdb.db.manager.get_manager(cls)

Returns the appropriate Manager class for a given Model class. It does this by looking in the boto config for a section like this:

[DB]
db_type = SimpleDB
db_user = <aws access key id>
db_passwd = <aws secret access key>
db_name = my_domain
[DB_TestBasic]
db_type = SimpleDB
db_user = <another aws access key id>
db_passwd = <another aws secret access key>
db_name = basic_domain
db_port = 1111

The values in the DB section are “generic values” that will be used if nothing more specific is found. You can also create a section for a specific Model class that gives the db info for that class. In the example above, TestBasic is a Model subclass.

boto.sdb.db.manager.pgmanager

Note

This module requires psycopg2 to be installed in the Python path.

boto.sdb.db.manager.sdbmanager

class boto.sdb.db.manager.sdbmanager.SDBConverter(manager)

Responsible for converting base Python types to format compatible with underlying database. For SimpleDB, that means everything needs to be converted to a string when stored in SimpleDB and from a string when retrieved.

To convert a value, pass it to the encode or decode method. The encode method will take a Python native value and convert to DB format. The decode method will take a DB format value and convert it to Python native format. To find the appropriate method to call, the generic encode/decode methods will look for the type-specific method by searching for a method called “encode_<type name>” or “decode_<type name>”.

decode(item_type, value)
decode_blob(value)
decode_bool(value)
decode_date(value)
decode_datetime(value)
decode_float(value)
decode_int(value)
decode_list(prop, value)
decode_long(value)
decode_map(prop, value)
decode_map_element(item_type, value)

Decode a single element for a map

decode_prop(prop, value)
decode_reference(value)
decode_string(value)

Decoding a string is really nothing, just return the value as-is

decode_time(value)

converts strings in the form of HH:MM:SS.mmmmmm (created by datetime.time.isoformat()) to datetime.time objects.

Timzone-aware strings (“HH:MM:SS.mmmmmm+HH:MM”) won’t be handled right now and will raise TimeDecodeError.

encode(item_type, value)
encode_blob(value)
encode_bool(value)
encode_date(value)
encode_datetime(value)
encode_float(value)

See http://tools.ietf.org/html/draft-wood-ldapext-float-00.

encode_int(value)
encode_list(prop, value)
encode_long(value)
encode_map(prop, value)
encode_prop(prop, value)
encode_reference(value)
encode_string(value)

Convert ASCII, Latin-1 or UTF-8 to pure Unicode

encode_time(value)
class boto.sdb.db.manager.sdbmanager.SDBManager(cls, db_name, db_user, db_passwd, db_host, db_port, db_table, ddl_dir, enable_ssl, consistent=None)
count(cls, filters, quick=True, sort_by=None, select=None)

Get the number of results that would be returned in this query

decode_value(prop, value)
delete_key_value(obj, name)
delete_object(obj)
domain
encode_value(prop, value)
get_blob_bucket(bucket_name=None)
get_key_value(obj, name)
get_object(cls, id, a=None)
get_object_from_id(id)
get_property(prop, obj, name)
get_raw_item(obj)
get_s3_connection()
load_object(obj)
query(query)
query_gql(query_string, *args, **kwds)
save_object(obj, expected_value=None)
sdb
set_key_value(obj, name, value)
set_property(prop, obj, name, value)
exception boto.sdb.db.manager.sdbmanager.TimeDecodeError

boto.sdb.db.manager.xmlmanager

class boto.sdb.db.manager.xmlmanager.XMLConverter(manager)

Responsible for converting base Python types to format compatible with underlying database. For SimpleDB, that means everything needs to be converted to a string when stored in SimpleDB and from a string when retrieved.

To convert a value, pass it to the encode or decode method. The encode method will take a Python native value and convert to DB format. The decode method will take a DB format value and convert it to Python native format. To find the appropriate method to call, the generic encode/decode methods will look for the type-specific method by searching for a method called “encode_<type name>” or “decode_<type name>”.

decode(item_type, value)
decode_bool(value)
decode_datetime(value)
decode_int(value)
decode_long(value)
decode_password(value)
decode_prop(prop, value)
decode_reference(value)
encode(item_type, value)
encode_bool(value)
encode_datetime(value)
encode_int(value)
encode_long(value)
encode_password(value)
encode_prop(prop, value)
encode_reference(value)
get_text_value(parent_node)
class boto.sdb.db.manager.xmlmanager.XMLManager(cls, db_name, db_user, db_passwd, db_host, db_port, db_table, ddl_dir, enable_ssl)
decode_value(prop, value)
delete_key_value(obj, name)
delete_object(obj)
encode_value(prop, value)
get_doc()
get_key_value(obj, name)
get_list(prop_node, item_type)
get_object(cls, id)
get_object_from_doc(cls, id, doc)
get_property(prop, obj, name)
get_props_from_doc(cls, id, doc)

Pull out the properties from this document Returns the class, the properties in a hash, and the id if provided as a tuple :return: (cls, props, id)

get_raw_item(obj)
get_s3_connection()
load_object(obj)
marshal_object(obj, doc=None)
new_doc()
query(cls, filters, limit=None, order_by=None)
query_gql(query_string, *args, **kwds)
reset()
save_list(doc, items, prop_node)
save_object(obj, expected_value=None)

Marshal the object and do a PUT

set_key_value(obj, name, value)
set_property(prop, obj, name, value)
unmarshal_object(fp, cls=None, id=None)
unmarshal_props(fp, cls=None, id=None)

Same as unmarshalling an object, except it returns from “get_props_from_doc”

boto.sdb.db.model

class boto.sdb.db.model.Expando(id=None, **kw)
class boto.sdb.db.model.Model(id=None, **kw)
classmethod all(limit=None, next_token=None)
delete()
classmethod find(limit=None, next_token=None, **params)
classmethod find_property(prop_name)
classmethod find_subclass(name)

Find a subclass with a given name

classmethod from_xml(fp)
classmethod get_by_id(ids=None, parent=None)
classmethod get_by_ids(ids=None, parent=None)
classmethod get_by_key_name(key_names, parent=None)
classmethod get_lineage()
classmethod get_or_insert(key_name, **kw)
classmethod get_xmlmanager()
id = None
key()
classmethod kind()
load()
classmethod properties(hidden=True)
put(expected_value=None)
reload()
save(expected_value=None)
set_manager(manager)
to_dict()
to_xml(doc=None)
class boto.sdb.db.model.ModelMeta(name, bases, dict)

Metaclass for all Models

boto.sdb.db.property

class boto.sdb.db.property.BlobProperty(verbose_name=None, name=None, default=None, required=False, validator=None, choices=None, unique=False)
data_type

alias of Blob

type_name = 'blob'
class boto.sdb.db.property.BooleanProperty(verbose_name=None, name=None, default=False, required=False, validator=None, choices=None, unique=False)
data_type

alias of bool

empty(value)
type_name = 'Boolean'
class boto.sdb.db.property.CalculatedProperty(verbose_name=None, name=None, default=None, required=False, validator=None, choices=None, calculated_type=<type 'int'>, unique=False, use_method=False)
get_value_for_datastore(model_instance)
class boto.sdb.db.property.DateProperty(verbose_name=None, auto_now=False, auto_now_add=False, name=None, default=None, required=False, validator=None, choices=None, unique=False)
data_type

alias of date

default_value()
get_value_for_datastore(model_instance)
now()
type_name = 'Date'
validate(value)
class boto.sdb.db.property.DateTimeProperty(verbose_name=None, auto_now=False, auto_now_add=False, name=None, default=None, required=False, validator=None, choices=None, unique=False)
data_type

alias of datetime

default_value()
get_value_for_datastore(model_instance)
now()
type_name = 'DateTime'
validate(value)
class boto.sdb.db.property.FloatProperty(verbose_name=None, name=None, default=0.0, required=False, validator=None, choices=None, unique=False)
data_type

alias of float

empty(value)
type_name = 'Float'
validate(value)
class boto.sdb.db.property.IntegerProperty(verbose_name=None, name=None, default=0, required=False, validator=None, choices=None, unique=False, max=2147483647, min=-2147483648)
data_type

alias of int

empty(value)
type_name = 'Integer'
validate(value)
class boto.sdb.db.property.ListProperty(item_type, verbose_name=None, name=None, default=None, **kwds)
data_type

alias of list

default_value()
empty(value)
type_name = 'List'
validate(value)
class boto.sdb.db.property.LongProperty(verbose_name=None, name=None, default=0, required=False, validator=None, choices=None, unique=False)
data_type

alias of long

empty(value)
type_name = 'Long'
validate(value)
class boto.sdb.db.property.MapProperty(item_type=<type 'str'>, verbose_name=None, name=None, default=None, **kwds)
data_type

alias of dict

default_value()
empty(value)
type_name = 'Map'
validate(value)
class boto.sdb.db.property.PasswordProperty(verbose_name=None, name=None, default='', required=False, validator=None, choices=None, unique=False, hashfunc=None)

Hashed property whose original value can not be retrieved, but still can be compared.

Works by storing a hash of the original value instead of the original value. Once that’s done all that can be retrieved is the hash.

The comparison

obj.password == ‘foo’

generates a hash of ‘foo’ and compares it to the stored hash.

Underlying data type for hashing, storing, and comparing is boto.utils.Password. The default hash function is defined there ( currently sha512 in most cases, md5 where sha512 is not available )

It’s unlikely you’ll ever need to use a different hash function, but if you do, you can control the behavior in one of two ways:

  1. Specifying hashfunc in PasswordProperty constructor

    import hashlib

    class MyModel(model):

    password = PasswordProperty(hashfunc=hashlib.sha224)

  2. Subclassing Password and PasswordProperty

    class SHA224Password(Password):

    hashfunc=hashlib.sha224

    class SHA224PasswordProperty(PasswordProperty):

    data_type=MyPassword type_name=”MyPassword”

    class MyModel(Model):

    password = SHA224PasswordProperty()

The hashfunc parameter overrides the default hashfunc in boto.utils.Password.

The remaining parameters are passed through to StringProperty.__init__

data_type

alias of Password

get_value_for_datastore(model_instance)
make_value_from_datastore(value)
type_name = 'Password'
validate(value)
class boto.sdb.db.property.Property(verbose_name=None, name=None, default=None, required=False, validator=None, choices=None, unique=False)
data_type

alias of str

default_validator(value)
default_value()
empty(value)
get_choices()
get_value_for_datastore(model_instance)
make_value_from_datastore(value)
name = ''
type_name = ''
validate(value)
verbose_name = ''
class boto.sdb.db.property.ReferenceProperty(reference_class=None, collection_name=None, verbose_name=None, name=None, default=None, required=False, validator=None, choices=None, unique=False)
check_instance(value)
check_uuid(value)
data_type

alias of Key

type_name = 'Reference'
validate(value)
class boto.sdb.db.property.S3KeyProperty(verbose_name=None, name=None, default=None, required=False, validator=None, choices=None, unique=False)
data_type

alias of Key

get_value_for_datastore(model_instance)
type_name = 'S3Key'
validate(value)
validate_regex = '^s3:\\/\\/([^\\/]*)\\/(.*)$'
class boto.sdb.db.property.StringProperty(verbose_name=None, name=None, default='', required=False, validator=<function validate_string>, choices=None, unique=False)
type_name = 'String'
class boto.sdb.db.property.TextProperty(verbose_name=None, name=None, default='', required=False, validator=None, choices=None, unique=False, max_length=None)
type_name = 'Text'
validate(value)
class boto.sdb.db.property.TimeProperty(verbose_name=None, name=None, default=None, required=False, validator=None, choices=None, unique=False)
data_type

alias of time

type_name = 'Time'
validate(value)
boto.sdb.db.property.validate_string(value)

boto.sdb.db.query

class boto.sdb.db.query.Query(model_class, limit=None, next_token=None, manager=None)
count(quick=True)
fetch(limit, offset=0)

Not currently fully supported, but we can use this to allow them to set a limit in a chainable method

filter(property_operator, value)
get_next_token()
get_query()
next()
next_token
order(key)
set_next_token(token)
to_xml(doc=None)

boto.sdb.domain

Represents an SDB Domain

class boto.sdb.domain.Domain(connection=None, name=None)
batch_delete_attributes(items)

Delete multiple items in this domain.

Parameters:items (dict or dict-like object) –

A dictionary-like object. The keys of the dictionary are the item names and the values are either:

  • dictionaries of attribute names/values, exactly the same as the attribute_names parameter of the scalar put_attributes call. The attribute name/value pairs will only be deleted if they match the name/value pairs passed in.
  • None which means that all attributes associated with the item should be deleted.
Return type:bool
Returns:True if successful
batch_put_attributes(items, replace=True)

Store attributes for multiple items.

Parameters:
  • items (dict or dict-like object) – A dictionary-like object. The keys of the dictionary are the item names and the values are themselves dictionaries of attribute names/values, exactly the same as the attribute_names parameter of the scalar put_attributes call.
  • replace (bool) – Whether the attribute values passed in will replace existing values or will be added as addition values. Defaults to True.
Return type:

bool

Returns:

True if successful

delete()

Delete this domain, and all items under it

delete_attributes(item_name, attributes=None, expected_values=None)

Delete attributes from a given item.

Parameters:
  • item_name (string) – The name of the item whose attributes are being deleted.
  • attributes (dict, list or boto.sdb.item.Item) – Either a list containing attribute names which will cause all values associated with that attribute name to be deleted or a dict or Item containing the attribute names and keys and list of values to delete as the value. If no value is supplied, all attribute name/values for the item will be deleted.
  • expected_value (list) –

    If supplied, this is a list or tuple consisting of a single attribute name and expected value. The list can be of the form:

    • [‘name’, ‘value’]

    In which case the call will first verify that the attribute “name” of this item has a value of “value”. If it does, the delete will proceed, otherwise a ConditionalCheckFailed error will be returned. The list can also be of the form:

    • [‘name’, True|False]

    which will simply check for the existence (True) or non-existence (False) of the attribute.

Return type:

bool

Returns:

True if successful

delete_item(item)
endElement(name, value, connection)
from_xml(doc)

Load this domain based on an XML document

get_attributes(item_name, attribute_name=None, consistent_read=False, item=None)

Retrieve attributes for a given item.

Parameters:
  • item_name (string) – The name of the item whose attributes are being retrieved.
  • attribute_names (string or list of strings) – An attribute name or list of attribute names. This parameter is optional. If not supplied, all attributes will be retrieved for the item.
Return type:

boto.sdb.item.Item

Returns:

An Item mapping type containing the requested attribute name/values

get_item(item_name, consistent_read=False)

Retrieves an item from the domain, along with all of its attributes.

Parameters:
  • item_name (string) – The name of the item to retrieve.
  • consistent_read (bool) – When set to true, ensures that the most recent data is returned.
Return type:

boto.sdb.item.Item or None

Returns:

The requested item, or None if there was no match found

get_metadata()
new_item(item_name)
put_attributes(item_name, attributes, replace=True, expected_value=None)

Store attributes for a given item.

Parameters:
  • item_name (string) – The name of the item whose attributes are being stored.
  • attribute_names (dict or dict-like object) – The name/value pairs to store as attributes
  • expected_value (list) –

    If supplied, this is a list or tuple consisting of a single attribute name and expected value. The list can be of the form:

    • [‘name’, ‘value’]

    In which case the call will first verify that the attribute “name” of this item has a value of “value”. If it does, the delete will proceed, otherwise a ConditionalCheckFailed error will be returned. The list can also be of the form:

    • [‘name’, True|False]

    which will simply check for the existence (True) or non-existence (False) of the attribute.

  • replace (bool) – Whether the attribute values passed in will replace existing values or will be added as addition values. Defaults to True.
Return type:

bool

Returns:

True if successful

select(query='', next_token=None, consistent_read=False, max_items=None)

Returns a set of Attributes for item names within domain_name that match the query. The query must be expressed in using the SELECT style syntax rather than the original SimpleDB query language.

Parameters:query (string) – The SimpleDB query to be performed.
Return type:iter
Returns:An iterator containing the results. This is actually a generator function that will iterate across all search results, not just the first page.
startElement(name, attrs, connection)
to_xml(f=None)

Get this domain as an XML DOM Document :param f: Optional File to dump directly to :type f: File or Stream

Returns:File object where the XML has been dumped to
Return type:file
class boto.sdb.domain.DomainDumpParser(domain)

SAX parser for a domain that has been dumped

characters(ch)
endElement(name)
startElement(name, attrs)
class boto.sdb.domain.DomainMetaData(domain=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.sdb.domain.UploaderThread(domain)

Uploader Thread

run()

boto.sdb.item

class boto.sdb.item.Item(domain, name='', active=False)

A dict sub-class that serves as an object representation of a SimpleDB item. An item in SDB is similar to a row in a relational database. Items belong to a Domain, which is similar to a table in a relational database.

The keys on instances of this object correspond to attributes that are stored on the SDB item.

Tip

While it is possible to instantiate this class directly, you may want to use the convenience methods on boto.sdb.domain.Domain for that purpose. For example, boto.sdb.domain.Domain.get_item().

Parameters:
add_value(key, value)

Helps set or add to attributes on this item. If you are adding a new attribute that has yet to be set, it will simply create an attribute named key with your given value as its value. If you are adding a value to an existing attribute, this method will convert the attribute to a list (if it isn’t already) and append your new value to said list.

For clarification, consider the following interactive session:

>>> item = some_domain.get_item('some_item')
>>> item.has_key('some_attr')
False
>>> item.add_value('some_attr', 1)
>>> item['some_attr']
1
>>> item.add_value('some_attr', 2)
>>> item['some_attr']
[1, 2]
Parameters:
  • key (str) – The attribute to add a value to.
  • value (object) – The value to set or append to the attribute.
decode_value(value)
delete()

Deletes this item in SDB.

Note

This local Python object remains in its current state after deletion, this only deletes the remote item in SDB.

endElement(name, value, connection)
load()

Loads or re-loads this item’s attributes from SDB.

Warning

If you have changed attribute values on an Item instance, this method will over-write the values if they are different in SDB. For any local attributes that don’t yet exist in SDB, they will be safe.

save(replace=True)

Saves this item to SDB.

Parameters:replace (bool) – If True, delete any attributes on the remote SDB item that have a None value on this object.
startElement(name, attrs, connection)

boto.sdb.persist

boto.sdb.persist.checker

boto.sdb.persist.object

boto.sdb.persist.property

boto.sdb.queryresultset

class boto.sdb.queryresultset.QueryResultSet(domain=None, query='', max_items=None, attr_names=None)
class boto.sdb.queryresultset.SelectResultSet(domain=None, query='', max_items=None, next_token=None, consistent_read=False)
next()
boto.sdb.queryresultset.query_lister(domain, query='', max_items=None, attr_names=None)
boto.sdb.queryresultset.select_lister(domain, query='', max_items=None)