Note
You are viewing the documentation for an older version of boto (boto2).
Boto3, the next version of Boto, is now stable and recommended for general use. It can be used side-by-side with Boto in the same project, so it is easy to start using Boto3 in your existing projects as well as new projects. Going forward, API updates and all new feature work will be focused on Boto3.
For more information, see the documentation for boto3.
SDB DB Reference¶
This module offers an ORM-like layer on top of SimpleDB.
boto.sdb.db¶
boto.sdb.db.blob¶
boto.sdb.db.key¶
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.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)¶ Handles both Dates and DateTime objects
-
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)¶
-
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¶
boto.sdb.db.model¶
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
boto.sdb.db.blob.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
__builtin__.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
datetime.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)¶ This class handles both the datetime.datetime object And the datetime.date objects. It can return either one, depending on the value stored in the database
-
data_type
¶ alias of
datetime.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
__builtin__.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
__builtin__.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
__builtin__.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
__builtin__.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
__builtin__.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:
Specifying hashfunc in PasswordProperty constructor
import hashlib
- class MyModel(model):
password = PasswordProperty(hashfunc=hashlib.sha224)
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
boto.utils.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
__builtin__.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
boto.sdb.db.key.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
boto.s3.key.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
datetime.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)¶
-