Ejemplo n.º 1
0
def add(cate, title, url, content, author):
    mc.delete('as:%s'%author)
    mc.delete('ac:%s'%cate)
    cursor = get_cursor()
    sql = 'insert into article (cate, title, url, content, author) values ' \
        '(%s, %s, %s, %s, %s)'
    params = (cate, title, url, content, author)
    try:
        cursor.execute(sql, params)
        cursor.connection.commit()
        return True
    except:
        cursor.connection.rollback()
        return False
Ejemplo n.º 2
0
def add(cate, title, url, content, author):
    mc.delete('as:%s' % author)
    mc.delete('ac:%s' % cate)
    cursor = get_cursor()
    sql = 'insert into article (cate, title, url, content, author) values ' \
        '(%s, %s, %s, %s, %s)'
    params = (cate, title, url, content, author)
    try:
        cursor.execute(sql, params)
        cursor.connection.commit()
        return True
    except:
        cursor.connection.rollback()
        return False
Ejemplo n.º 3
0
 def delete(self):
     cursor = get_cursor()
     sql = 'delete from article where id = %s'
     params = (self.id)
     cursor.execute(sql, params)
     cursor.connection.commit()
     mc.delete('a:%s'%self.id)
     mc.delete('as:%s'%self.author)
     mc.delete('ac:%s'%self.cate)
Ejemplo n.º 4
0
 def delete(self):
     cursor = get_cursor()
     sql = 'delete from article where id = %s'
     params = (self.id)
     cursor.execute(sql, params)
     cursor.connection.commit()
     mc.delete('a:%s' % self.id)
     mc.delete('as:%s' % self.author)
     mc.delete('ac:%s' % self.cate)
Ejemplo n.º 5
0
 def update(self, old_cate):
     cursor = get_cursor()
     sql = 'update article set title=%s, cate=%s, url=%s, content=%s, author=%s ' \
         'where id=%s'
     params = (self.title, self.cate, self.url, self.content, self.author, self.id)
     cursor.execute(sql, params)
     cursor.connection.commit()
     mc.delete('a:%s'%self.id)
     if self.cate != old_cate:
         mc.delete('ac:%s'%self.cate)
         mc.delete('ac:%s'%old_cate)
Ejemplo n.º 6
0
 def update(self, old_cate):
     cursor = get_cursor()
     sql = 'update article set title=%s, cate=%s, url=%s, content=%s, author=%s ' \
         'where id=%s'
     params = (self.title, self.cate, self.url, self.content, self.author,
               self.id)
     cursor.execute(sql, params)
     cursor.connection.commit()
     mc.delete('a:%s' % self.id)
     if self.cate != old_cate:
         mc.delete('ac:%s' % self.cate)
         mc.delete('ac:%s' % old_cate)