<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          peewee輕量級的python ORM

          聯(lián)合創(chuàng)作 · 2023-09-30 03:04

          peewee 是一個輕量級的 python ORM 庫。內(nèi)建對 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
          瀏覽 26
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产精品18欠久久久久久 | 日本伊人大香蕉视频 | 亚洲黄色视频在线免费观看 | 99伊人网| 久久嫩草精品久久久久 |