All Projects → coleifer → Peewee

coleifer / Peewee

Licence: mit
a small, expressive orm -- supports postgresql, mysql and sqlite

Programming Languages

python
139335 projects - #7 most used programming language
cython
566 projects

Projects that are alternatives of or similar to Peewee

TwitterPiBot
A Python based bot for Raspberry Pi that grabs tweets with a specific hashtag and reads them out loud.
Stars: ✭ 85 (-99.04%)
Mutual labels:  sqlite, peewee
Warp
Convert and analyze large data sets at light speed, on Mac and iOS.
Stars: ✭ 62 (-99.3%)
Mutual labels:  sqlite
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+3.81%)
Mutual labels:  sqlite
Moor
Moor is an easy to use, reactive, typesafe persistence library for Dart & Flutter
Stars: ✭ 1,090 (-87.63%)
Mutual labels:  sqlite
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (-99.42%)
Mutual labels:  sqlite
Sql.js
A javascript library to run SQLite on the web.
Stars: ✭ 9,594 (+8.89%)
Mutual labels:  sqlite
Easycaching
💥 EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Stars: ✭ 1,047 (-88.12%)
Mutual labels:  sqlite
Doomlauncher
Doom Launcher is a doom launching utility and database for custom wads and pk3s
Stars: ✭ 63 (-99.28%)
Mutual labels:  sqlite
Blazor Wasm Identity Grpc
Blazor WASM, IdentityServer4, Kestrel Web Server, Entity Framework Code First SQLite Database with Multiple Roles, Additional User Claims & gRPC with Roles Authorization.
Stars: ✭ 61 (-99.31%)
Mutual labels:  sqlite
Esp32 Idf Sqlite3
Sqlite library for esp-idf (esp32) framework
Stars: ✭ 57 (-99.35%)
Mutual labels:  sqlite
Nodbi
Document DBI connector for R
Stars: ✭ 56 (-99.36%)
Mutual labels:  sqlite
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-99.41%)
Mutual labels:  sqlite
Tinano
A typesafe sqlite persistence library for flutter
Stars: ✭ 59 (-99.33%)
Mutual labels:  sqlite
Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (-99.42%)
Mutual labels:  sqlite
Android tmdb clean architecture
Showcase of clean architecture concepts along with Continuous Integration and Development for modular Android applications. Includes test suits (functional and unit tests) along with code coverage.
Stars: ✭ 63 (-99.28%)
Mutual labels:  sqlite
Dbal
Doctrine Database Abstraction Layer
Stars: ✭ 8,495 (-3.59%)
Mutual labels:  sqlite
Ios Sdk
AppSpector is a debugging service for mobile apps
Stars: ✭ 56 (-99.36%)
Mutual labels:  sqlite
Kirby3 Autoid
Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL.
Stars: ✭ 58 (-99.34%)
Mutual labels:  sqlite
Indonesia Postal And Area
Indonesia Postal Code & Area (BPS)
Stars: ✭ 64 (-99.27%)
Mutual labels:  sqlite
Sqlite orm
❤️ SQLite ORM light header only library for modern C++
Stars: ✭ 1,121 (-87.28%)
Mutual labels:  sqlite

https://media.charlesleifer.com/blog/photos/peewee3-logo.png

peewee

Peewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use.

  • a small, expressive ORM
  • python 2.7+ and 3.4+ (developed with 3.6)
  • supports sqlite, mysql, postgresql and cockroachdb
  • tons of extensions
https://travis-ci.org/coleifer/peewee.svg?branch=master

New to peewee? These may help:

Examples

Defining models is similar to Django or SQLAlchemy:

from peewee import *
import datetime


db = SqliteDatabase('my_database.db')

class BaseModel(Model):
    class Meta:
        database = db

class User(BaseModel):
    username = CharField(unique=True)

class Tweet(BaseModel):
    user = ForeignKeyField(User, backref='tweets')
    message = TextField()
    created_date = DateTimeField(default=datetime.datetime.now)
    is_published = BooleanField(default=True)

Connect to the database and create tables:

db.connect()
db.create_tables([User, Tweet])

Create a few rows:

charlie = User.create(username='charlie')
huey = User(username='huey')
huey.save()

# No need to set `is_published` or `created_date` since they
# will just use the default values we specified.
Tweet.create(user=charlie, message='My first tweet')

Queries are expressive and composable:

# A simple query selecting a user.
User.get(User.username == 'charlie')

# Get tweets created by one of several users.
usernames = ['charlie', 'huey', 'mickey']
users = User.select().where(User.username.in_(usernames))
tweets = Tweet.select().where(Tweet.user.in_(users))

# We could accomplish the same using a JOIN:
tweets = (Tweet
          .select()
          .join(User)
          .where(User.username.in_(usernames)))

# How many tweets were published today?
tweets_today = (Tweet
                .select()
                .where(
                    (Tweet.created_date >= datetime.date.today()) &
                    (Tweet.is_published == True))
                .count())

# Paginate the user table and show me page 3 (users 41-60).
User.select().order_by(User.username).paginate(3, 20)

# Order users by the number of tweets they've created:
tweet_ct = fn.Count(Tweet.id)
users = (User
         .select(User, tweet_ct.alias('ct'))
         .join(Tweet, JOIN.LEFT_OUTER)
         .group_by(User)
         .order_by(tweet_ct.desc()))

# Do an atomic update
Counter.update(count=Counter.count + 1).where(Counter.url == request.url)

Check out the example twitter app.

Learning more

Check the documentation for more examples.

Specific 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 on GitHub.

Still want more info?

https://media.charlesleifer.com/blog/photos/wat.jpg

I'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:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].