Пример #1
0
#   Create a test entity
test_entity = Entity('test_entity', 'test_id', {
    'test':'1',
    'b':'2'
}, db)

#   Create an index on test_entity for property 'test' and 'b'
test_entity.add_index(Index(test_entity, 'test', db))
test_entity.add_index(Index(test_entity, 'b', db))

#   Create Entity and Associated Index Tables
test_entity.create_table()

#   Lets create an entity without providing any data.
try:
    test = test_entity.create({})
except EntityError, e:
    print e
else:
    print 'Created Entity successfully, should of thrown error, missing index'

#   Lets actually give it the proper parameters
test = test_entity.create({
    'test':'abc123',
    'b':'hello'
})

#   Now lets try finding it by id, then by index test and b
print test_entity.find(id=test['id'])
print test_entity.find(test=test['test'])
print test_entity.find(b=test['b'])