title: How do I "generate" a web API from a database?
body: <p>I'd like to automatically generate a web API from a database. I can easily query the database with SQL, but obviously this won't do for a public API. I can also write the server-side code manually, but this will take a very long time, since the database is fairly large. Also, writing it manually would be a very mechanical and repetitive task, so I don't see why a program can't do it for me.</p>
  
  <p>For example, let's say I have a table in my database called "Announcements". I'm looking for a way to (given that database table), automatically generate the server-side code that will allow someone to create new announcements, requiring the correct fields. Done manually, this could look like a PHP file called "create_announcement.php", which requires all the fields that exist in the database, like the announcement title, body, and author. Of course, this could also be done in a cleaner way by following some design model (like REST), but this is meant as an example.</p>
  
  <p>Other things I'm considering are:</p>
  
  <ul>
  <li>Some form of authentication. For example, if the user would like to delete an announcement, he/she should be required to "log in" to do so. I'm not sure how this works here.</li>
  <li>Some way to add logic. If I can generate an API to access the database through HTTP (as I tried to describe above), the API will not be aware of certain specificities. Let's say the announcement resource should include a date that must be <em>after</em> today. I need a way to express that in the code.</li>
  <li>It would be ideal if the solution could follow some design model to make it easier to access from different clients.</li>
  </ul>
  
  <p>So what kind of tools should I look into? What is the general approach people take when confronted with this problem?</p>