예제 #1
0
time.sleep(1)

clothing = Entity()
clothing.PartitionKey = 'clothingstore'
clothing.RowKey = '006'
clothing.sku = 'BLK203143'
clothing.item = 'jeans'
clothing.cost = 55.99
table_service.insert_entity('itemstable', clothing)
print('Created entry for Jeans...\n')
time.sleep(1)

cars = Entity()
cars.PartitionKey = 'carsmenu'
cars.RowKey = '008'
cars.Make = 'Mercedes-Benz'
cars.model = 'C300'
cars.year = 2018
cars.color = 'Blue'
cars.price = 38000
table_service.insert_entity('itemstable', cars)
print('Created entry for Mercedes-Benz...')
time.sleep(1)

coffee = Entity()
coffee.PartitionKey = 'coffeemenu'
coffee.RowKey = '008'
coffee.brand = 'Tim Hortons'
coffee.flavor = 'Double Double'
coffee.size = 'Large'
coffee.price = 3
###
# Use the Azure Storage Storage SDK for Python to create some entries in the Table
###
print('Now let\'s add some entries to our Table.\nRemember, Azure Storage Tables is a NoSQL datastore, so this is similar to adding records to a database.')
raw_input('Press Enter to continue...')

# Each entry in a Table is called an 'Entity'. 
# Here, we add an entry for first car with two pieces of data - the name, and the Year
#
# A partition key tracks how like-minded entries in the Table are created and queried.
# A row key is a unique ID for each entity in the partition
# These two properties are used as a primary key to index the Table. This makes queries much quicker.

car = Entity()
car.PartitionKey = 'carinfo'
car.Make = 'Honda'
car.Model = 'Civic'
car.Year = 2015
car.Color = 'RED'
car.Price = 25,000
table_service.insert_entity('itemstable', car)
print('Created entry for HONDA...\n')

car = Entity()
car.PartitionKey = 'carinfo'
car.Make = 'Tesla'
car.Model = 'Model 3'
car.Year = 2015
car.Color = 'BLACK'
car.Price = 60,000
table_service.insert_entity('itemstable', car)