peewee

Sagteware kiekie:
peewee
Sagteware besonderhede:
Weergawe: 2.2.1
Upload datum: 14 Apr 15
Ontwikkelaar: Charles Leifer
Lisensie: Gratis
Populariteit: 37

Rating: nan/5 (Total Votes: 0)

snuiter - vroetel rond met 'n ORM.
model definisies en skema skepping
ruik soos Django:
invoer snuiter
klas Blog (peewee.Model):
& Nbsp; title = peewee.CharField ()
& Nbsp; def __unicode __ (self):
& Nbsp; terugkeer self.title
klas Entry (peewee.Model):
& Nbsp; title = peewee.CharField (MAX_LENGTH = 50)
& Nbsp; content = peewee.TextField ()
& Nbsp; pub_date = peewee.DateTimeField ()
& Nbsp; blog = peewee.ForeignKeyField (blog)
& Nbsp; def __unicode __ (self):
& Nbsp; terugkeer "% s:% s '% (self.blog.title, self.title)
skep 'n paar tafels:
>>> Blog.create_table ()
>>> Entry.create_table ()
vreemde sleutels werk soos Django se
& Nbsp; >>> b = Blog (title = "Snuiters en Muggies se Big Adventure")
& Nbsp; >>> b.save ()
& Nbsp; >>> e = Entry (title = "? Grootste fliek ooit", inhoud = "Ja", blog = b)
& Nbsp; >>> e.save ()
& Nbsp; >>> e.blog
& Nbsp;
& Nbsp; >>> vir e in b.entry_set:
& Nbsp; ... druk e.title
& Nbsp; ...
& Nbsp; Grootste fliek ooit?
bisarre bevraagteken
navrae kom in 4 geure (kies / update / insetsel / verwyder):
>>> Vir i in xrange (50):
... B = Blog (title = 'blog-% d'% i)
... B.save ()
... Vir j in xrange (i):
... E = Entry (title = 'Entry-% d'% j, blog = b)
... E.save ()
...
>>> [Obj.title vir obj in Blog.select (). Waar (title__contains = "0")]
[U'blog-0 ', u'blog-10', u'blog-20 ', u'blog-30', u'blog-40 ']
>>> [Obj.title vir obj in Blog.select (). Pagineren (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 vir obj in Blog.select (). Aansluit (Entry) .where (title__contains = 'intreevlak-45')]
[U'blog-46 ', u'blog-47', u'blog-48 ', u'blog-49']
>>> Blog.select (). Aansluit (Entry) .where (title__contains = 'intreevlak-29). Tel ()
20

Vereistes :

  • Python

Ander sagteware ontwikkelaar Charles Leifer

beefish
beefish

20 Feb 15

peewee
peewee

20 Jul 15

djutils
djutils

11 May 15

Kommentaar te peewee

Kommentaar nie gevind
Kommentaar te lewer
Draai op die foto!