Next would be:
"SELECT id FROM artworks WHERE position >= %s and id > %s ORDER BY position, id LIMIT 1"
and prev would be:
"SELECT id FROM artworks WHERE position <= %s and id < %s ORDER BY position DESC, id DESC LIMIT 1"
The position comparison has to be >= not just > because it might be the same as the previous.