-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrderTable.py
72 lines (65 loc) · 3.55 KB
/
OrderTable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#coding:utf8
from azure.storage import TableService, Entity
import json
class OrderTable:
def __init__(self):
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
def insert(self,ID,CustomerID,ProductID,Datetime,TotalPrice):
task = {'PartitionKey': 'Order',
'RowKey': ID,
'CustomerID' : CustomerID,
'ProductID' : ProductID,
'Datetime' : Datetime,
'TotalPrice' : TotalPrice}
try:
self.table_service.insert_entity('Order', task)
except:
print"azure.WindowsAzureConflictError: Order Conflict"
def listAll(self):
task1 = self.table_service.query_entities('Order', None, None, 1000)
task2 = self.table_service.query_entities('Order', None, None, 1000,
task1.x_ms_continuation['NextPartitionKey'],
task1.x_ms_continuation['NextRowKey'])
task3 = self.table_service.query_entities('Order', None, None, 1000,
task2.x_ms_continuation['NextPartitionKey'],
task2.x_ms_continuation['NextRowKey'])
task4 = self.table_service.query_entities('Order', None, None, 1000,
task3.x_ms_continuation['NextPartitionKey'],
task3.x_ms_continuation['NextRowKey'])
'''
task5 = self.table_service.query_entities('Order', None, None, 1000,
task4.x_ms_continuation['NextPartitionKey'],
task4.x_ms_continuation['NextRowKey'])
task6 = self.table_service.query_entities('Order', None, None, 1000,
task5.x_ms_continuation['NextPartitionKey'],
task5.x_ms_continuation['NextRowKey'])
task7 = self.table_service.query_entities('Order', None, None, 1000,
task6.x_ms_continuation['NextPartitionKey'],
task6.x_ms_continuation['NextRowKey'])
task8 = self.table_service.query_entities('Order', None, None, 1000,
task7.x_ms_continuation['NextPartitionKey'],
task7.x_ms_continuation['NextRowKey'])
task9 = self.table_service.query_entities('Order', None, None, 1000,
task8.x_ms_continuation['NextPartitionKey'],
task8.x_ms_continuation['NextRowKey'])
task10 = self.table_service.query_entities('Order', None, None, 1000,
task9.x_ms_continuation['NextPartitionKey'],
task9.x_ms_continuation['NextRowKey'])
'''
i=0
for task in task1:
i=i+1
'''
print("ID: %s, CustomerID: %s, ProductID: %s, Datetime: %s, TotalPrice: %s") %(task.RowKey,
task.CustomerID,task.ProductID,task.Datetime,task.TotalPrice)
'''
print(task.TotalPrice)
for task in task2:
i=i+1
print(task.TotalPrice)
print("Total Order: %s") %(i)
def TableInfo(self):
info=self.table_service.query_tables()
for i in info:
print(i.name)