示例#1
0
文件: init_db.py 项目: Funyapu/PawLog
 def get(self):
   dir = "model/data"
   with open('%s/PetType.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           PetType.get_or_insert(
             row[0],
             name=row[0],
             name_ja=row[1],
             behavior=row[2].split("|")
           )
   
   with open('%s/PetCategory.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           PetCategory.get_or_insert(
             row[1],
             name=row[1],
             pet_type=ndb.Key(PetType, row[0]),
             name_ja=row[2]
           )
   
   with open('%s/BreedDog.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           Breed.get_or_insert(
             row[1],
             pet_type=ndb.Key(PetType, row[0]),
             name=row[1],
             name_ja=row[2]
           )
   with open('%s/BreedCat.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           Breed.get_or_insert(
             row[1],
             pet_type=ndb.Key(PetType, row[0]),
             name=row[1],
             name_ja=row[2]
           )
示例#2
0
文件: Pet.py 项目: Funyapu/PawLog
 def get(self):
   data = {}
   data["pet_types"] = PetType.get()
   data["pet_categories"] = PetCategory.get()
   
   self.SendJson(data)