Пример #1
0
 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
 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)