Bottle + MongoDB Example

Mar 17, 2011 BottleMongoDBpython

A didactic Web application written in Python to illustrate how to use the Bottle web-framework with the MongoDB database.

It’s a port I made of Mike Dirolf’s DjanMon application (how to use Django with MongoDB).

Bottle is a wonderful micro web-framework, it’s beautifully written and documented and has that “just right” feel about it. Bottle has support for multiple webservers and template engines – I’m really enjoying it after working with Django.

MongoDB is a schemaless document-oriented database designed for the Web. For me, working with MongoDB has been a revelation. Database creation, administration and migration (long the bane of database developers) is trivial in comparison with traditional SQL databases. Document storage management is baked into MongoDB and is used in many web applications (document storage has always been awkward and slow with relational databases).

You can find the source on GitHub.

Here’s a screenshot:


To run the application install the prerequisite packages then:

git clone
cd bottle-mongodb-example

The application creates and displays a paged list of user created messages which are stored in a MongoDB database along with uploaded images (no file system management required it’s all in the database) – not bad for 93 lines of Python code and a 79 line HTML template. The really neat thing is that you don’t have to create the database, tables or schema – it all happens automatically.


I’m running in this environment – it works for me but your mileage may vary:

« Previous Next »