コード例 #1
0
 def user_to_dynamodb(self):
     UserModel.create_table(read_capacity_units=1, write_capacity_units=1)
     user = UserModel(self.user['id'])
     user.screen_name  = self.user['screen_name']
     user.gender  = self.user['gender']
     user.statuses_count  = self.user['statuses_count']
     user.followers_count  = self.user['followers_count']
     user.follow_count  = self.user['follow_count']
     user.registration_time = self.user['registration_time']
     user.sunshine = self.user['sunshine']
     user.birthday = self.user['birthday']
     user.location = self.user['location']
     user.education = self.user['education']
     user.company = self.user['company']
     user.description  = self.user['description']
     user.profile_url  = self.user['profile_url']
     user.profile_image_url  = self.user['profile_image_url']
     user.avatar_hd  = self.user['avatar_hd']
     user.urank  = self.user['urank']
     user.mbrank  = self.user['mbrank']
     user.verified  = self.user['verified']
     user.verified_type  = self.user['verified_type']
     user.verified_reason  = self.user['verified_reason']
     user.save()
コード例 #2
0
from model import UserModel

# Create Table
UserModel.create_table(read_capacity_units=1, write_capacity_units=1)

# Insert
user = UserModel("John", "Denver")
user.save()

# Count
print("Count:", UserModel.count())

# Query
for user in UserModel.query("Smith", first_name__begins_with="J"):
    print(user.first_name)

# Get
try:
    user = UserModel.get("John", "Denver")
    print(user)
except UserModel.DoesNotExist:
    print("User does not exist")