num=int(db.execute("SELECT number from movies WHERE id = ?",(dest,)).fetchone()["number"])
movies=db.execute("SELECT id FROM movies WHERE number >= ? ORDER BY number",(num,)).fetchall()
nb=num+1
formovieinmovies:
db.execute("UPDATE movies SET number = ? WHERE id = ?",(nb,movie["id"]))
nb+=1
db.execute("UPDATE movies SET number = ? WHERE id = ?",(num,src))
db.commit()
defget_movies():
returnget_db().execute("SELECT id, title, year, poster, plot, watched, watchDate, score FROM movies ORDER BY number").fetchall()
defget_movies_to_watch():
returnget_db().execute("SELECT id, title, year, poster, plot, watched, watchDate, score FROM movies WHERE watched = 0 ORDER BY number").fetchall()
defget_watched_movies():
returnget_db().execute("SELECT id, title, year, poster, plot, watched, watchDate, score FROM movies WHERE watched = 1 ORDER BY watchDate DESC").fetchall()
defnew_movie(movie):
db=get_db()
movie["id"]=db.execute("INSERT INTO movies (title, year, poster, plot, number) VALUES (?,?,?,?,?) RETURNING id",