Пример #1
0
 def insert(self,session):
     container = db.Container(session,self)
     for idx,variable_name in enumerate(self.variables):
         clean_units = db.get_or_create(session,db.CleanUnits,**self.clean_units[idx])
         clean_variable = db.get_or_create(session,db.CleanVariable,**self.clean_variable[idx])
         rv = db.Field(self,container,variable_name,clean_units,clean_variable)
         session.add(rv)
     session.commit()
Пример #2
0
 def insert(self,session):
     dc = db.get_or_create(session,db.DatasetCategory,**self.dataset_category)
     qq = session.query(db.Field).join(db.Container).join(db.Uri)
     uris = []
     variables = []
     for f in self.fields:
         uris += f().uri
         variables += f.variables
     qq = qq.filter(db.Uri.value.in_(uris))
     qq = qq.filter(db.Field.name.in_(variables))
     assert(qq.count() == len(self.fields))
     dp = db.DataPackage(field=qq.all(),name=self.name,description=self.description,dataset_category=dc)
     session.add(dp)
     session.commit()