What I usually do is keep a separate class (eg this horrible jumble of code ) that has all the database magic including the actual SQL and I call its functions everywhere else. Easy to play with
@ThiefMaster I could run django or flask or whatever, and I find them both pretty fun, but others don't know python that well and I have more experience (not much though) with php. If I need to whip something up, php becomes the best choice