peewee Documentation Release 1.0.0group_by('id').join(Tweet).order_by(('count', 'desc')) # do an atomic update TweetCount.update(count=F('count') + 1).where(user=charlie) You can use django-style syntax to create select queries: # how superusers To perform lookups against another column in a given row, use the F object: >>> Employee.filter(salary__lt=F('desired_salary')) Check the docs for more examples of querying. Sorting records serialize_object(stat) Performing atomic updates Use the special F object to perform an atomic update: >>> MessageCount.update(count=F('count') + 1).where(user=some_user) Aggregating records Suppose0 码力 | 101 页 | 163.20 KB | 1 年前3
peewee Documentation Release 0.9.7group_by('id').join(Tweet).order_by(('count', 'desc')) # do an atomic update TweetCount.update(count=F('count') + 1).where(user=charlie) You can use django-style syntax to create select queries: # how superusers To perform lookups against another column in a given row, use the F object: >>> Employee.filter(salary__lt=F('desired_salary')) Sorting records >>> for e in Entry.select().order_by('pub_date'): serialize_object(stat) Performing atomic updates Use the special F object to perform an atomic update: >>> MessageCount.update(count=F('count') + 1).where(user=some_user) Aggregating records Suppose0 码力 | 78 页 | 143.68 KB | 1 年前3
peewee Documentation
Release 1.0.0group_by(’id’).join(Tweet).order_by((’count’, ’desc’)) # do an atomic update TweetCount.update(count=F(’count’) + 1).where(user=charlie) You can use django-style syntax to create select queries: # how superusers To perform lookups against another column in a given row, use the F object: >>> Employee.filter(salary__lt=F(’desired_salary’)) Check the docs for more examples of querying. Sorting records serialize_object(stat) Performing atomic updates Use the special F object to perform an atomic update: >>> MessageCount.update(count=F(’count’) + 1).where(user=some_user) Aggregating records Suppose0 码力 | 71 页 | 405.29 KB | 1 年前3
peewee Documentation
Release 0.9.7group_by(’id’).join(Tweet).order_by((’count’, ’desc’)) # do an atomic update TweetCount.update(count=F(’count’) + 1).where(user=charlie) You can use django-style syntax to create select queries: # how superusers To perform lookups against another column in a given row, use the F object: >>> Employee.filter(salary__lt=F(’desired_salary’)) Sorting records >>> for e in Entry.select().order_by(’pub_date’): serialize_object(stat) Performing atomic updates Use the special F object to perform an atomic update: >>> MessageCount.update(count=F(’count’) + 1).where(user=some_user) Aggregating records Suppose0 码力 | 53 页 | 347.03 KB | 1 年前3
peewee Documentation
Release 2.0.2expressing the same User.select( User, fn.Count(Tweet.id).alias(’ct’) ).join(Tweet).group_by(User).order_by(R(’ct desc’)) # do an atomic update Counter.update(count=Counter.count + 1).where( Counter.url == request atomic update on a counter model (you’ll have to use your imagination): # 1.0 Counter.update(count=F(’count’) + 1).where(url=request.url) 1.3. Upgrading peewee 5 peewee Documentation, Release 2.0.0 request.url) Let’s find all the users whose username starts with ‘a’ or ‘A’: # 1.0 User.select().where(R(’LOWER(SUBSTR(username, 1, 1)) = %s’, ’a’)) # 2.0 User.select().where(fn.Lower(fn.Substr(User.username0 码力 | 65 页 | 315.33 KB | 1 年前3
peewee Documentation Release 3.0.0username)) def login_required(f): @wraps(f) def inner(*args, **kwargs): if not session.get('logged_in'): return redirect(url_for('login')) return f(*args, **kwargs) return data into a PostgreSQL database using the following commands: createdb peewee_test psql -U postgres -f clubdata.sql -d peewee_test -x -q To create the schema using Peewee, without loading the sample data (surname, firstname). SELECT m.firstname, m.surname, r.firstname, r.surname FROM members AS m LEFT OUTER JOIN members AS r ON (m.recommendedby = r.memid) ORDER BY m.surname, m.firstname MA = Member.alias()0 码力 | 319 页 | 361.50 KB | 1 年前3
peewee Documentation Release 3.4.0username)) def login_required(f): @wraps(f) def inner(*args, **kwargs): if not session.get('logged_in'): return redirect(url_for('login')) return f(*args, **kwargs) return data into a PostgreSQL database using the following commands: createdb peewee_test psql -U postgres -f clubdata.sql -d peewee_test -x -q To create the schema using Peewee, without loading the sample data (surname, firstname). SELECT m.firstname, m.surname, r.firstname, r.surname FROM members AS m LEFT OUTER JOIN members AS r ON (m.recommendedby = r.memid) ORDER BY m.surname, m.firstname MA = Member.alias()0 码力 | 349 页 | 382.34 KB | 1 年前3
peewee Documentation
Release 3.5.0username)) def login_required(f): @wraps(f) def inner(*args, **kwargs): if not session.get('logged_in'): return redirect(url_for('login')) return f(*args, **kwargs) return net/MySQLdb.html#some-mysql-examples] MySQL: pymysql [https://github.com/PyMySQL/PyMySQL/blob/f08f01fe8a59e8acfb5f5add4a8fe874bec2a196/pymysql/co nnections.py#L494-L513] SQLite: sqlite3 [https://docs.python otherwise it will open a new connection. >>> db.connection()f94e9362f10> Connection Pooling Connection pooling is provided by the pool module, included in the playhouse 0 码力 | 347 页 | 380.80 KB | 1 年前3
peewee Documentation Release 3.1.0username)) def login_required(f): @wraps(f) def inner(*args, **kwargs): if not session.get('logged_in'): return redirect(url_for('login')) return f(*args, **kwargs) return data into a PostgreSQL database using the following commands: createdb peewee_test psql -U postgres -f clubdata.sql -d peewee_test -x -q To create the schema using Peewee, without loading the sample data (surname, firstname). SELECT m.firstname, m.surname, r.firstname, r.surname FROM members AS m LEFT OUTER JOIN members AS r ON (m.recommendedby = r.memid) ORDER BY m.surname, m.firstname MA = Member.alias()0 码力 | 332 页 | 370.77 KB | 1 年前3
peewee Documentation Release 3.6.0username)) def login_required(f): @wraps(f) def inner(*args, **kwargs): if not session.get('logged_in'): return redirect(url_for('login')) return f(*args, **kwargs) return net/MySQLdb.html#some-mysql-examples] MySQL: pymysql [https://github.com/PyMySQL/PyMySQL/blob/f08f01fe8a59e8acfb5f5add4a8fe874bec2a196/pymysql/co nnections.py#L494-L513] SQLite: sqlite3 [https://docs.python otherwise it will open a new connection. >>> db.connection()f94e9362f10> Connection Pooling Connection pooling is provided by the pool module, included in the playhouse 0 码力 | 377 页 | 399.12 KB | 1 年前3
共 16 条
- 1
- 2













