示例#1
0
文件: user.py 项目: huhuchen/luffy
 def add(cls, uid, name, type):
     try:
         id = store.execute("insert into user (uid, name, type) values "
                            "(%s, %s, %s)", (uid, name, type))
         store.commit()
     except IntegrityError:
         store.rollback()
         return
     return cls.get(id)
示例#2
0
文件: card.py 项目: huhuchen/luffy
 def add(cls, title, content, author_uid):
     try:
         id = store.execute(
             "insert into card (title, content, author_uid, creation_time) " "values(%s, %s, %s, null)",
             (title, content, author_uid),
         )
         store.commit()
     except IntegrityError:
         store.rollback()
         return
     return cls.get(id)
示例#3
0
文件: card.py 项目: huhuchen/luffy
 def _get_ids(cls):
     rs = store.execute("select id from card order by id desc")
     return [r[0] for r in rs if r]
示例#4
0
文件: card.py 项目: huhuchen/luffy
 def get(cls, id):
     rs = store.execute(
         "select id, title, content, author_uid, creation_time, " "update_time from card where id=%s", (id,)
     )
     if rs:
         return cls(*rs[0])
示例#5
0
文件: card.py 项目: huhuchen/luffy
 def delete(self):
     store.execute("delete from card where id=%s", self.id)
     store.commit()
示例#6
0
文件: card.py 项目: huhuchen/luffy
 def update(self, title, content):
     store.execute("update card set title=%s, content=%s where id=%s", (title, content, self.id))
     store.commit()
     self.title = title
     self.content = content
示例#7
0
文件: user.py 项目: huhuchen/luffy
 def get_by_uid(cls, uid):
     rs = store.execute("select id, uid, name, type, subtype, birthday from user "
                        "where uid=%s", uid)
     if rs:
         return cls(*rs[0])
示例#8
0
文件: user.py 项目: huhuchen/luffy
 def delete(self):
     store.execute('delete from user where id=%s', self.id)
     store.commit()