update database.py and web.py for pagination