{"id":13400004,"url":"https://github.com/coleifer/peewee","last_synced_at":"2025-05-12T16:18:36.298Z","repository":{"id":37432128,"uuid":"979480","full_name":"coleifer/peewee","owner":"coleifer","description":"a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb","archived":false,"fork":false,"pushed_at":"2025-05-01T12:38:35.000Z","size":15234,"stargazers_count":11520,"open_issues_count":0,"forks_count":1374,"subscribers_count":197,"default_branch":"master","last_synced_at":"2025-05-12T16:18:29.527Z","etag":null,"topics":["dank","gametight","peewee","python","sqlite"],"latest_commit_sha":null,"homepage":"http://docs.peewee-orm.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coleifer.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2010-10-11T20:14:11.000Z","updated_at":"2025-05-12T14:40:38.000Z","dependencies_parsed_at":"2024-01-14T20:12:45.164Z","dependency_job_id":"66261f48-7dac-44e0-9c6e-207d048c5c38","html_url":"https://github.com/coleifer/peewee","commit_stats":{"total_commits":4307,"total_committers":150,"mean_commits":"28.713333333333335","dds":"0.12769909449732997","last_synced_commit":"e31ec0074682e7f14f45c150eef17daeada49d49"},"previous_names":[],"tags_count":197,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fpeewee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fpeewee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fpeewee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fpeewee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coleifer","download_url":"https://codeload.github.com/coleifer/peewee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253774593,"owners_count":21962199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dank","gametight","peewee","python","sqlite"],"created_at":"2024-07-30T19:00:46.409Z","updated_at":"2025-05-12T16:18:36.276Z","avatar_url":"https://github.com/coleifer.png","language":"Python","readme":".. image:: https://media.charlesleifer.com/blog/photos/peewee3-logo.png\n\npeewee\n======\n\nPeewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use.\n\n* a small, expressive ORM\n* python 2.7+ and 3.4+\n* supports sqlite, mysql, mariadb, postgresql\n* tons of `extensions \u003chttp://docs.peewee-orm.com/en/latest/peewee/playhouse.html\u003e`_\n\nNew to peewee? These may help:\n\n* `Quickstart \u003chttp://docs.peewee-orm.com/en/latest/peewee/quickstart.html#quickstart\u003e`_\n* `Example twitter app \u003chttp://docs.peewee-orm.com/en/latest/peewee/example.html\u003e`_\n* `Using peewee interactively \u003chttp://docs.peewee-orm.com/en/latest/peewee/interactive.html\u003e`_\n* `Models and fields \u003chttp://docs.peewee-orm.com/en/latest/peewee/models.html\u003e`_\n* `Querying \u003chttp://docs.peewee-orm.com/en/latest/peewee/querying.html\u003e`_\n* `Relationships and joins \u003chttp://docs.peewee-orm.com/en/latest/peewee/relationships.html\u003e`_\n\nExamples\n--------\n\nDefining models is similar to Django or SQLAlchemy:\n\n.. code-block:: python\n\n    from peewee import *\n    import datetime\n\n\n    db = SqliteDatabase('my_database.db')\n\n    class BaseModel(Model):\n        class Meta:\n            database = db\n\n    class User(BaseModel):\n        username = CharField(unique=True)\n\n    class Tweet(BaseModel):\n        user = ForeignKeyField(User, backref='tweets')\n        message = TextField()\n        created_date = DateTimeField(default=datetime.datetime.now)\n        is_published = BooleanField(default=True)\n\nConnect to the database and create tables:\n\n.. code-block:: python\n\n    db.connect()\n    db.create_tables([User, Tweet])\n\nCreate a few rows:\n\n.. code-block:: python\n\n    charlie = User.create(username='charlie')\n    huey = User(username='huey')\n    huey.save()\n\n    # No need to set `is_published` or `created_date` since they\n    # will just use the default values we specified.\n    Tweet.create(user=charlie, message='My first tweet')\n\nQueries are expressive and composable:\n\n.. code-block:: python\n\n    # A simple query selecting a user.\n    User.get(User.username == 'charlie')\n\n    # Get tweets created by one of several users.\n    usernames = ['charlie', 'huey', 'mickey']\n    users = User.select().where(User.username.in_(usernames))\n    tweets = Tweet.select().where(Tweet.user.in_(users))\n\n    # We could accomplish the same using a JOIN:\n    tweets = (Tweet\n              .select()\n              .join(User)\n              .where(User.username.in_(usernames)))\n\n    # How many tweets were published today?\n    tweets_today = (Tweet\n                    .select()\n                    .where(\n                        (Tweet.created_date \u003e= datetime.date.today()) \u0026\n                        (Tweet.is_published == True))\n                    .count())\n\n    # Paginate the user table and show me page 3 (users 41-60).\n    User.select().order_by(User.username).paginate(3, 20)\n\n    # Order users by the number of tweets they've created:\n    tweet_ct = fn.Count(Tweet.id)\n    users = (User\n             .select(User, tweet_ct.alias('ct'))\n             .join(Tweet, JOIN.LEFT_OUTER)\n             .group_by(User)\n             .order_by(tweet_ct.desc()))\n\n    # Do an atomic update (for illustrative purposes only, imagine a simple\n    # table for tracking a \"count\" associated with each URL). We don't want to\n    # naively get the save in two separate steps since this is prone to race\n    # conditions.\n    Counter.update(count=Counter.count + 1).where(Counter.url == request.url)\n\nCheck out the `example twitter app \u003chttp://docs.peewee-orm.com/en/latest/peewee/example.html\u003e`_.\n\nLearning more\n-------------\n\nCheck the `documentation \u003chttp://docs.peewee-orm.com/\u003e`_ for more examples.\n\nSpecific question? Come hang out in the #peewee channel on irc.libera.chat, or post to the mailing list, http://groups.google.com/group/peewee-orm . If you would like to report a bug, `create a new issue \u003chttps://github.com/coleifer/peewee/issues/new\u003e`_ on GitHub.\n\nStill want more info?\n---------------------\n\n.. image:: https://media.charlesleifer.com/blog/photos/wat.jpg\n\nI've written a number of blog posts about building applications and web-services with peewee (and usually Flask). If you'd like to see some real-life applications that use peewee, the following resources may be useful:\n\n* `Building a note-taking app with Flask and Peewee \u003chttps://charlesleifer.com/blog/saturday-morning-hack-a-little-note-taking-app-with-flask/\u003e`_ as well as `Part 2 \u003chttps://charlesleifer.com/blog/saturday-morning-hacks-revisiting-the-notes-app/\u003e`_ and `Part 3 \u003chttps://charlesleifer.com/blog/saturday-morning-hacks-adding-full-text-search-to-the-flask-note-taking-app/\u003e`_.\n* `Analytics web service built with Flask and Peewee \u003chttps://charlesleifer.com/blog/saturday-morning-hacks-building-an-analytics-app-with-flask/\u003e`_.\n* `Personalized news digest (with a boolean query parser!) \u003chttps://charlesleifer.com/blog/saturday-morning-hack-personalized-news-digest-with-boolean-query-parser/\u003e`_.\n* `Structuring Flask apps with Peewee \u003chttps://charlesleifer.com/blog/structuring-flask-apps-a-how-to-for-those-coming-from-django/\u003e`_.\n* `Creating a lastpass clone with Flask and Peewee \u003chttps://charlesleifer.com/blog/creating-a-personal-password-manager/\u003e`_.\n* `Creating a bookmarking web-service that takes screenshots of your bookmarks \u003chttps://charlesleifer.com/blog/building-bookmarking-service-python-and-phantomjs/\u003e`_.\n* `Building a pastebin, wiki and a bookmarking service using Flask and Peewee \u003chttps://charlesleifer.com/blog/dont-sweat-small-stuff-use-flask-blueprints/\u003e`_.\n* `Encrypted databases with Python and SQLCipher \u003chttps://charlesleifer.com/blog/encrypted-sqlite-databases-with-python-and-sqlcipher/\u003e`_.\n* `Dear Diary: An Encrypted, Command-Line Diary with Peewee \u003chttps://charlesleifer.com/blog/dear-diary-an-encrypted-command-line-diary-with-python/\u003e`_.\n* `Query Tree Structures in SQLite using Peewee and the Transitive Closure Extension \u003chttps://charlesleifer.com/blog/querying-tree-structures-in-sqlite-using-python-and-the-transitive-closure-extension/\u003e`_.\n","funding_links":[],"categories":["Python","HarmonyOS","ORM","资源列表","Database","Data Management \u0026 Processing","This is my awesome list of everything in life  :blush:","python","数据库管理系统","CONTENTS","ORMs \u0026 Query Builders","ORM [🔝](#readme)","📚 فهرست","Awesome Python","Database Clients","ODM, ORM, Active Record"],"sub_categories":["Windows Manager","ORM","Database \u0026 Cloud Management","ORM's:","网络服务_其他","Базы_данных","Python","دیتابیس"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoleifer%2Fpeewee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoleifer%2Fpeewee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoleifer%2Fpeewee/lists"}