예제 #1
0
 def post(self,):
     if not self.request.arguments:
         self.render("chart/schema_insert.html")
     else:
         session = Session()
         M = make_table_model("system_chartschema")
         m = M()
         for k, v in self.request.arguments.items():
             setattr(m, k, v[0])
         session.add(m)
         session.commit()
         session.close()
         return self.redirect("/chart/schema/")
예제 #2
0
def save_records(records):
    session = Session()
    for r in records:
        try:
            r = eval(r)
            tablename = r['tablename']
            data = r['data']
            M = make_table_model(tablename.encode('utf-8'))   
            m = M()
            for k,v in data.items():
                setattr(m,k,v)
            session.add(m)
            logger.debug('%s save %s'%(tablename,str(m)))
        except Exception,e:
            logger.error(traceback.format_exc(e))