-
Notifications
You must be signed in to change notification settings - Fork 2
/
Store.py
42 lines (41 loc) · 1.23 KB
/
Store.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
from Object import Object
debug= False
class Store(Object):
def __init__(self):
self.name1= "player:"
self.name2= "store:"
self.primarykey1="Owner" #PlayerID
self.primarykey2="ShopID"
self.sql="select * from GShopStore;"
def write2Redis(self):
self.getDataFromDB()
index1=-1
index2=-1
for i in range(len(self.head)):
if(self.head[i] == self.primarykey1):
index1=i
break
for i in range(len(self.head)):
if(self.head[i]==self.primarykey2):
index2=i
break
if(index1== -1):
return
if(index2== -1):
return
for iLine in self.results:
objID1=self.name1+str(iLine[index1])
objID2=self.name2+str(iLine[index2])
command="hmset "+objID1+objID2+" "
for i in range( len(self.head) ):
command = command + self.head[i]+" "+str(iLine[i])+" "
if(debug):
print command
from exeRedis import Redis
redis = Redis()
redis.exe(command)
return True
#Test
if(__name__=="__main__"):
t=Store()
t.write2Redis()