mod_accounting is a simple Apache module that can record traffic statistics into a database (bytes in/out per http request).
NOTE: this project has been abandoned years ago. The code in the repository needs some fixing in order to be usable.
Also, it needs a security review, especially in the query building part: as it is, %h, %R and %e placeholders could lead to SQL injection.
If anyone wishes to maintain the project, just let me know.