def index(): now = datetime.datetime.now() nowtime = now.strftime("%Y-%m-%d %H:%M:%S") if request.method != "POST": return "" if "password" not in request.form: return "" if request.form["password"] != password: return "" if "success" not in request.form: d = collections.OrderedDict() x = db.select("info", where="flag=0") if len(x) != 0: for key in x: d[key.msgid] = key.con db.insert("log", msgid=key.msgid, time=nowtime, state="send") return json.dumps(d) else: return "" else: msgid = request.form["success"] if msgid.isdigit(): try: db.update("info", where="msgid=$msgid", flag=1, vars=locals()) db.insert("log", msgid=msgid, time=nowtime, state="receive") except: pass return ""
def index(): now = datetime.datetime.now() nowtime = now.strftime('%Y-%m-%d %H:%M:%S') if request.method != 'POST': return "" if 'password' not in request.form: return "" if request.form['password'] != password: return "" if 'success' not in request.form: d = collections.OrderedDict() x = db.select('info', where="flag=0") if len(x) != 0: for key in x: d[key.msgid] = key.con db.insert("log", msgid=key.msgid, time=nowtime, state="send") return json.dumps(d) else: return "" else: msgid = request.form['success'] if msgid.isdigit(): try: db.update('info', where='msgid=$msgid', flag=1, vars=locals()) db.insert("log", msgid=msgid, time=nowtime, state="receive") except: pass return ""
def add_from_reading(cls, db, key, reading): """Adds a reading to the database :param reading: the reading to add """ # get allowed channels allowed_channels = key.get_writable_channels() insert_count = 0 # start a transaction with db.transaction(): # insert samples, checking channel access for sample in reading.sample_dict_gen(): if sample["channel"] not in allowed_channels: raise Exception("Channel {0} cannot be writen to with \ specified key".format(sample["channel"])) db.insert(cls.TABLE_NAME, \ channel=sample["channel"], timestamp=sample["timestamp"], \ value=sample["value"]) insert_count += 1 return insert_count
def register(username, password, telephone, wechat, icon): db = connectDB() mmd5 = hashlib.md5() mmd5.update(password) pwd = mmd5.hexdigest() if not wechat: db.insert('user', username = username, password = pwd, telephone = telephone, icon = icon) else: db.insert('user', username = username, password = pwd, telephone = telephone, wechat = wechat, icon = icon)
def release(userid, demand, quote, destination): db = web.database( dbn = 'mysql', host = sae.const.MYSQL_HOST, port = int(sae.const.MYSQL_PORT), user = sae.const.MYSQL_USER, passwd = sae.const.MYSQL_PASS, db = sae.const.MYSQL_DB ) orderid = db.insert('orders', dmd = demand, quote = quote, requestid = userid, destination = destination) db.insert('dmdpool', orderid = orderid)
def update_note_content(id, content, data=''): if id is None: return if content is None: content = '' if data is None: data = '' db = xtables.get_note_content_table() result = db.select_first(where=dict(id=id)) if result is None: db.insert(id=id, content=content, data=data) else: db.update(where=dict(id=id), content=content, data=data)
def register(username, password, telephone, wechat, icon): db = web.database( dbn = 'mysql', host = sae.const.MYSQL_HOST, port = int(sae.const.MYSQL_PORT), user = sae.const.MYSQL_USER, passwd = sae.const.MYSQL_PASS, db = sae.const.MYSQL_DB ) mmd5 = hashlib.md5() mmd5.update(password) pwd = mmd5.hexdigest() if not wechat: db.insert('user', username = username, password = pwd, telephone = telephone, icon = icon) else: db.insert('user', username = username, password = pwd, telephone = telephone, wechat = wechat, icon = icon)
def AddUserMessage(userid, clienttime, inputmsg,isvalid): # Response and session if isvalid == 1: session = get_session(userid, inputmsg) response = get_response(userid, inputmsg) else: response = '' session = '' # Insert to db utctime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(time.time())) id = db.insert('User_Message', UserOpenId=userid, ClientTime=clienttime, UTCTIME = utctime, InputMessage=inputmsg, Version = numVersion, IsValid = isvalid, Session = session, Response = response) # id reserve for future use return response
def create_note(note_dict): content = note_dict["content"] data = note_dict["data"] creator = note_dict["creator"] priority = note_dict["priority"] mtime = note_dict["mtime"] if xconfig.DB_ENGINE == "sqlite": db = xtables.get_file_table() id = db.insert(**note_dict) update_note_content(id, content, data) return id else: id = dbutil.timeseq() key = "note_full:%s" % id note_dict["id"] = id dbutil.put(key, note_dict) score = "%02d:%s" % (priority, mtime) dbutil.zadd("note_recent:%s" % creator, score, id) update_children_count(note_dict["parent_id"]) return id
def new_todo(text): return db.insert('todo', titel=text)
def insert_URL(_url, _push_id): db.insert("URL", url = _url, push_id = _push_id)
def add_new(user, username,phone,num,time): return db.insert('morning_enroll', user=user, username=username,phone=phone,num=num,time=time)
def addfk(username, fktime, fkcontent): return db.insert('fk', user=username, time=fktime, fk_content=fkcontent)
def insert_news(_url, _title, _image, _date, _word): db.insert("news", url = _url, title = _title, image = _image, date = _date, word = _word)
def get_insert(_table, _openID, _keyword): return db.insert(_table, openID = _openID, keyword = _keyword)
def insert_feedback(_user, _fktime, _fkcontent): db.insert("feedback", user = _user, fktime = _fktime, fkcontent = _fkcontent)
def add_new(username, time): return db.insert('morning_time_backup', username=username, sign_time=time)
def add_new(user,username,stuid,total,istoday,timetoday,all_record,phone): return db.insert('morning_sign', user=user, username=username,stuid=stuid,total=total,istoday=istoday,timetoday=timetoday,all_record=all_record,phone=phone)
def get_insert_feedback(_table, _user, _fktime, _fkcontent): return db.insert(_table, user = _user, fktime = _fktime, fkcontent = _fkcontent)
def get_insert_news(_table, _url, _title, _date): return db.insert(_table, url = _url, title = _title, date = _date)
def insert_push_time(_push_id, _time, _last_id): db.insert("push_time", push_id = _push_id, time = _time, last_id = _last_id)
def wuru(username, product_details): #New Product #Return product id product_id = db.insert('shareit', product_details = product_details, product_owner = username, product_user = username, checkcode_user = '******') return str(product_id)
def addip(addip): # 增加一个代理IP return db.insert('dailiip',ip=addip)
def release(userid, demand, quote, destination): db = connectDB() orderid = db.insert('orders', dmd = demand, quote = quote, requestid = userid, destination = destination) db.insert('dmdpool', orderid = orderid)
def insert_keyword(_push_id, _word): db.insert("keyword", push_id = _push_id, word = _word)