peewee

Software screenshot:
peewee
Software ətraflı:
Version: 2.2.1
Tarixi Upload: 14 Apr 15
Geliştirici: Charles Leifer
Lisenziya: Pulsuz
Məşhurluq: 1

Rating: nan/5 (Total Votes: 0)

peewee - bir ORM ilə ətrafında mənasız.
model anlayışlar və şeması yaradılması
Django kimi kokuyor:
idxal peewee
sinif Blog (peewee.Model):
& Nbsp; title = peewee.CharField ()
& Nbsp; def __unicode __ (özünü):
& Nbsp; qaytarılması self.title
class Giriş (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 __ (özünü):
& Nbsp; qaytarılması '% s:% s'% (self.blog.title, self.title)
Bəzi masalar yaratmaq:
>>> Blog.create_table ()
>>> Entry.create_table ()
xarici açarları Django nin kimi işləmək
& Nbsp; >>> b = Blog (title = "Peewee nin Big Adventure")
& Nbsp; >>> b.save ()
& Nbsp; >>> e = Giriş (title = "Heç Greatest film", content = "YES", blog = b)
& Nbsp; >>> e.save ()
& Nbsp; >>> e.blog
& Nbsp;
& Nbsp; >>> b.entry_set e üçün
& Nbsp; ... print e.title
& Nbsp; ...
& Nbsp; heç Greatest film?
qəribə querying
sorğu 4 tatlar (/ update / daxil / silmək seçin) gəlib:
>>> Xrange i üçün (50)
... B = Blog (title = 'Blog-% d'% i)
... B.save ()
... Xrange (i) j üçün:
... E = Giriş (title = 'giriş% d'% j, blog = b)
... E.save ()
...
>>> [Blog.select (). Ilə obj üçün obj.title olduğu (title__contains = '0')]
[U'blog-0, u'blog-10 ', u'blog-20', u'blog-30 ', u'blog-40']
>>> [Blog.select () və obj üçün obj.title. Paginate (3, 10)]
[U'blog-20 ', u'blog-21', u'blog-22 ', u'blog-23', u'blog-24 ',
& Nbsp; "u'blog-26 ', u'blog-27', u'blog-28 ', u'blog-29'-25 u'blog]
>>> [Blog.select () və obj üçün obj.title. Qoşulmaq (Giriş) .where (title__contains = 'giriş-45)]
[U'blog-46 ', u'blog-47', u'blog-48 ', u'blog-49']
>>> Blog.select (). Qoşulmaq (Giriş) .where (title__contains = 'giriş-29). Saymaq ()
20

tələblər

  • Python

Geliştirici digər proqram Charles Leifer

djutils
djutils

11 May 15

beefish
beefish

20 Feb 15

django-completion
django-completion

11 May 15

Şərh peewee

Şərhlər tapılmadı
Şərh əlavə
Images yandırın!