Exemplo n.º 1
0
 def edit_tread(id, name, board_id):
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute(
             'UPDATE tread SET name = %s, board_id = %s WHERE id = %s',
             (name, board_id, id))
     print("Edit tread with id %s", id)
Exemplo n.º 2
0
 def create_board(name):
     with db.cursor() as cursor:
         db.autocommit = True
         values = [(name)]
         insert = sql.SQL('INSERT INTO board (name) VALUES ({})').format(
             sql.SQL(',').join(map(sql.Literal, values)))
         cursor.execute(insert)
     print("create")
Exemplo n.º 3
0
 def get_board(id):
     ret = {}
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute('SELECT * FROM board WHERE board.id = %s;', id)
         for row in cursor:
             ret[row[0]] = {'name': row[1]}
     return ret
Exemplo n.º 4
0
 def get_all_boards():
     ret = {}
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute('SELECT * FROM board;')
         for row in cursor:
             ret[row[0]] = {'name': row[1]}
     return ret
Exemplo n.º 5
0
 def get_tread(id):
     ret = {}
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute('SELECT * FROM tread WHERE tread.id = %s;', id)
         for row in cursor:
             ret[row[0]] = {'name': row[1], 'board_id': row[2]}
     return ret
Exemplo n.º 6
0
 def create_message(author, text, tread_id):
     with db.cursor() as cursor:
         db.autocommit = True
         values = [(author, text, tread_id)]
         insert = sql.SQL(
             'INSERT INTO message (author, text, tread_id) VALUES {}'
         ).format(sql.SQL(',').join(map(sql.Literal, values)))
         cursor.execute(insert)
     print("create")
Exemplo n.º 7
0
 def get_message(id):
     ret = {}
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute('SELECT * FROM message WHERE message.id = %s;', id)
         for row in cursor:
             ret[row[0]] = {
                 'name': row[1],
                 'text': row[2],
                 'tread_id': row[3]
             }
     return ret
Exemplo n.º 8
0
 def edit_board(id, name):
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute('UPDATE board SET name = %s WHERE id = %s',
                        (name, id))
     print("edit board with id %s", id)
Exemplo n.º 9
0
 def delete_message(id):
     ret = {}
     with db.cursor() as cursor:
         db.autocommit = True
         cursor.execute('DELETE FROM message WHERE message.id = %s;', id)
     return ret