peewee

Phần mềm chụp màn hình:
peewee
Các chi tiết về phần mềm:
Phiên bản: 2.2.1
Ngày tải lên: 14 Apr 15
Nhà phát triển: Charles Leifer
Giấy phép: Miễn phí
Phổ biến: 1

Rating: nan/5 (Total Votes: 0)

peewee - quan trọng xung quanh với một ORM.
định nghĩa mô hình và tạo giản đồ
mùi giống như django:
peewee nhập khẩu
class Blog (peewee.Model):
& Nbsp; title = peewee.CharField ()
& Nbsp; def __unicode __ (self):
& Nbsp; trở self.title
class Entry (peewee.Model):
& Nbsp; title = peewee.CharField (max_length = 50)
& Nbsp; nội dung = peewee.TextField ()
& Nbsp; pub_date = peewee.DateTimeField ()
& Nbsp; blog = peewee.ForeignKeyField (Blog)
& Nbsp; def __unicode __ (self):
& Nbsp; return '% s:% s'% (self.blog.title, self.title)
tạo ra một số bảng:
>>> Blog.create_table ()
>>> Entry.create_table ()
phím nước ngoài làm việc như của django
& Nbsp; >>> b = Blog (title = "Big Adventure Peewee của")
& Nbsp; >>> b.save ()
& Nbsp; >>> e = Entry (title = "? Bộ phim vĩ đại nhất bao giờ", nội dung = "! YES", blog = b)
& Nbsp; >>> e.save ()
& Nbsp; >>> e.blog
& Nbsp;
& Nbsp; >>> cho e trong b.entry_set:
& Nbsp; ... in e.title
& Nbsp; ...
& Nbsp; bộ phim vĩ đại nhất bao giờ?
kỳ quái truy vấn
truy vấn đến 4 hương vị (chọn / update / insert / delete):
>>> For i in xrange (50):
... B = Blog (title = 'blog-% d "% i)
... B.save ()
... Cho j trong xrange (i):
... E = Entry (title = 'entry-% d'% j, blog = b)
... E.save ()
...
>>> [Obj.title cho obj trong Blog.select (). Nơi (title__contains = '0')]
[U'blog-0 ', u'blog-10', u'blog-20 ', u'blog-30', u'blog-40 ']
>>> [Obj.title cho obj trong Blog.select (). Đánh số trang (3, 10)]
[U'blog-20 ', u'blog-21', u'blog-22 ', u'blog-23', u'blog-24 ',
& Nbsp; u'blog-25 ', u'blog-26', u'blog-27 ', u'blog-28', u'blog-29 ']
>>> [Obj.title cho obj trong Blog.select (). Tham gia (Entry) .where (title__contains = "entry-45 ')]
[U'blog-46 ', u'blog-47', u'blog-48 ', u'blog-49']
>>> Blog.select (). Tham gia (Entry) .where ('entry-29' title__contains =). Count ()
20

Yêu cầu :

  • Python

Phần mềm khác của nhà phát triển Charles Leifer

django-completion
django-completion

11 May 15

django-news
django-news

11 May 15

redis-completion
redis-completion

20 Feb 15

Ý kiến ​​để peewee

Bình luận không
Nhập bình luận
Bật hình ảnh!