PHP vs. Python for RESTful Web API
… or maybe that should be the Slim Framework vs. ?? (something in python) for RESTful Web API.
My major concern regarding the backend framework selection is how cool parameterized queries work. PHP looks pretty straight forward, and using MySQLi seems to be the best practice, but there’s just something that seems dated with them.
For Python, however, I was able to find this code:
some_dictionary_with_the_data = {
'name': 'awesome song',
'artist': 'some band',
etc...
}
cursor.execute ("""
INSERT INTO Songs (SongName, SongArtist, SongAlbum, SongGenre,
SongLength, SongLocation)
VALUES
(%(name)s, %(artist)s, %(album)s, %(genre)s, %(length)s,
%(location)s)
""", some_dictionary_with_the_data)
Neat! Build a small array of variables, and pass that array to the string, nice!
In looking at RESTful Web APIs for python, I’ve momentarily given up. For now I’m going to get going on PHP with the Slim Framework, and if I need to change later, it shouldn’t be too painful.