ITPub博客

首页 > Linux操作系统 > Linux操作系统 > How Python MongoDB Toolkit Ming Can Ease Schema Maintenance

How Python MongoDB Toolkit Ming Can Ease Schema Maintenance

原创 Linux操作系统 作者:jieforest 时间:2012-06-13 06:21:05 0 删除 编辑
And now that you're all caught up, let's jump right in with Ming....

Why Ming?

If you've come to MongoDB from the world of relational databases, you have probably been struck by just how easy everything is: no big object/relational mapper needed, no new query language to learn (well, maybe a little, but we'll gloss over that for now), everything is just Python dictionaries, and it's so, so fast!

While this is all true to some extent, one of the big things you give up with MongoDB is structure.

MongoDB is sometimes referred to as a schema-free database. (This is not technically true; I find it more useful to think of MongoDB as having dynamically typed documents. The collection doesn't tell you anything about the type of documents it contains, but each individual document can be inspected.)

While this can be nice, as it's easy to evolve your schema quickly in development, it's easy to get yourself in trouble the first time your application tries to query by a field that only exists in some of your documents.

The fact of the matter is that even if the database cares nothing about your schema, your applicationdoes, and if you play too fast and lose with document structure, it will come back to haunt you in the end. The main reason Ming was created at SourceForge was to deal with just this problem. We wanted a (thin) layer on top of pymongo that would do a couple of things for us:

1. Make sure that we don't put malformed data into the database

2. Try to 'fix' malformed data coming back from the database

So, without belaboring the point of its existence, let's jump into Ming.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/301743/viewspace-732624/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    443
  • 访问量
    508609