peewee 轻量级的python ORM

程序名称:peewee

授权协议: MIT

操作系统: 跨平台

开发语言: Python

peewee 介绍

peewee一个轻量级的 python ORM 库。内建对 sqlite、MysqL 和 Postgresql支持支持 Python 2.6+ 和
Python 3.2+。

pip 安装:pip install peewee

示例代码

from peewee import *

db = sqliteDatabase('people.db')

class Person(Model):
    name = CharField()
    birthday = DateField()
    is_relative = BooleanField()

    class Meta:
        database = db # This model uses the "people.db" database.

>>> from datetime import date
>>> uncle_bob = Person(name='Bob', birthday=date(1960, 1, 15), is_relative=True)
>>> uncle_bob.save() # bob is Now stored in the database
1

>>> grandma = Person.select().where(Person.name == 'Grandma L.').get()
>>> grandma = Person.get(Person.name == 'Grandma L.')


>>> for person in Person.select():
...     print person.name, person.is_relative
...
Bob True
Grandma L. True
Herb False

高级用法

import peewee
from peewee import *

db = MysqLDatabase('jonhydb', user='john',passwd='megajonhy')

class Book(peewee.Model):
    author = peewee.CharField()
    title = peewee.TextField()

    class Meta:
        database = db

Book.create_table()
book = Book(author="me", title='peewee is cool')
book.save()
for book in Book.filter(author="me"):
    print book.title

peewee is cool

peewee 官网

http://peewee.readthedocs.org/

相关编程语言

BlazeDS 是一个基于服务器的Java 远程控制(remoting...
OVal 是一个可扩展的Java对象数据验证框架,验证的规...
Volta 是一套开发工具,专为开发分布式、实时系统应...
OpenDDS 是一个开源的 C++ 实现的 对象管理组织 OMG...
JADE (Java Agent DEvelopment Framework) 是一个完...
FastMM ,在D2006和2007中已代替了原来的内存管理器。