SQLITE3 python3.x类函数被调用两次

时间:2013-09-19 21:05:13

标签: python sqlite multiple-value

我不知道为什么,但每次调用一个函数时都会被调用两次

    def nicks(self, user, nick=None, mode="get"):
            db = w.connect("bots.db")
            c = db.cursor()

            if mode == "create":
                    c.execute('delete from nicks where user like("%s")' % (user))
                    c.execute('insert into nicks(user, nick, time) values("%s", "%s", "%s")' % (user, nick, set_time))
                    db.commit()
            elif mode == "ginfo":
                    nick = "".join([n[1] for n in c.fetchall()])
                    time = "".join([t[2] for t in c.fetchall()])
                    try: return "NICK_SET: %s TIME_SET: %s" % (nick, formatTime(time))
                    except Exception as e: return "NICK_SET: Not Found TIME_SET: Not Found"
            elif mode == "get":
                    try:
                         print("MODE: %s" % mode)
                         c.execute('select * from nicks where user like("%s")' % (user))
                         #nick = "".join([us[2] for us in c.fetchall()])
                         return ''.join([us[2] for us in c.fetchall()])
                    except: return user
  print(nicks(user="user", nick="nick", mode="create"))
  print(nicks(user="user"))
  return_value: nick
  return_value: nick

整个模块可以在http://yuribot.com/mod.txt

找到

0 个答案:

没有答案