Questions tagged [peewee]

peewee is a small ORM written in Python, providing a lightweight querying interface over SQL.

peewee is a small ORM written in Python. It provides a lightweight querying interface over SQL, and uses SQL concepts when querying, like joins and where clauses. It supports sqlite, mysql and postgresql.

1197 questions
0
votes
1 answer

peewee refers to a base class table that does not exist

The following set-up illustrates my problem: from peewee import (Model, SqliteDatabase) from peewee import (CharField, ForeignKeyField, IntegerField) from playhouse.shortcuts import…
lafras
  • 8,712
  • 4
  • 29
  • 28
0
votes
1 answer

WTForm does not entirely repopulate form data upon editing a model

Edit: Category field is now able to repopulate. Made a mistake in retrieving the data. App.py has been edited. I recently created an "edit post" form in which the user clicks on a link, and a few parameters are sent to a function. My function…
Guled
  • 659
  • 1
  • 5
  • 18
0
votes
2 answers

IN condition in Where clause on Peewee

I would like to accomplish something like an SQL 'IN' condition for the where clause in Python's Peewee ORM. Order.select().where(Order.statusid in statuses) Is this possible? I am using Postgres in case there is any compatibility issues with any…
gerosalesc
  • 2,983
  • 3
  • 27
  • 46
0
votes
2 answers

Delete an element from peewee Query select

I have a Query result by Peewee's table.select(), lets say that I want to delete a part of the resulting list(QuerySelect) how is that done? or exclude certain elements from the query? #Edited result = users.select(); for element in result: for…
Newbie
  • 386
  • 4
  • 19
0
votes
1 answer

API started, db killed, db started, peewee.InterfaceError connection already closed

Starting app.py, then killing the database and hitting /api/foo gives me: peewee.OperationalError: could not connect to server: Connection refused Bringing the database back up gives me and hitting /api/foo gives me: peewee.OperationalError:…
A T
  • 13,008
  • 21
  • 97
  • 158
0
votes
3 answers

Peewee throws KeyError when trying to add user defined operator

I followed the short guide in the peewee docs on how to add user defined operators, but when I try to do it, it gives me a KeyError. from peewee import * from peewee import OP from peewee import Expression db =…
Simon Brix
  • 102
  • 1
  • 10
0
votes
2 answers

Incorrect result in SQL. Subquery is borked, but why?

I have this Peewee query: stats = ( Assignment.select( Type.name, fn.COUNT(Type.id).alias('total'), Assignment.select( fn.COUNT(Assignment.id) ).where( (Assignment.due_date < fn.Now()) &…
commadelimited
  • 5,656
  • 6
  • 41
  • 77
0
votes
1 answer

Force TCP protocol on localhost in peewee

Can I force peewee to use TCP protocol rather than using a unix socket when making a MySQL localhost connection? It seems like peewee is assuming it can use a unix socket when I ask for a connection to localhost. The reason I need this is that the…
John L
  • 397
  • 3
  • 12
0
votes
1 answer

Relational Mapping using Peewee

I'm new to relational databases and I'm quite confused on how should I create the models. What I need need to get done is to filter the posts content through the language choice and to do that I need to create a relational database. My doubt comes…
Yelp
  • 75
  • 1
  • 3
  • 8
0
votes
1 answer

Join query for Postgres 9.4 JSONB field using Peewee ORM

Am using peewee in one of my projects and being from a Django background, i like it great. Am planning to use the newly introduced JSONB in postgres 9.4 extensively. However, I have no clue to how can I perform a join operation using JSONB keys. I…
Abhilash Nanda
  • 339
  • 2
  • 4
  • 13
0
votes
1 answer

Peewee: condensing two select queries into a join

So I'm trying to turn my double query into a join, here's what my peewee select queries look like: for app in AppInfo.select().limit(5): for event in EventHistory.select().where(EventHistory.appname==app.appname): print event So this is…
Stupid.Fat.Cat
  • 10,755
  • 23
  • 83
  • 144
0
votes
1 answer

How to convert this query to the Peewee ORM?

I'm using the (excellent) Peewee ORM for my query needs in Python and I now want to convert the following query: select t1.created, t1.property_id, t1.requesting_user_id, t1.type, t1.response from pdr t1 inner join ( select max(id) as id,…
kramer65
  • 50,427
  • 120
  • 308
  • 488
0
votes
1 answer

Fast table recreation

I want a empty database for each test so I recreate the database each time. This is really slow. Is there a faster way? my_dbmodule.DATABASE = ':memory: my_dbmodule.db =…
Sir l33tname
  • 4,026
  • 6
  • 38
  • 49
0
votes
0 answers

Peewee query results, unicode data not comparable to regular strings in list

I have a query built with peewee: nameGoEvidenceEarlier = Protein.select(Protein.entryname ,Evidence.evidencecode ,Go.go_domain, Go.go_term).join(ProteinGo).join(Evidence).switch(ProteinGo).join(Go).where(Evidence.ondate.year ==…
user2998764
  • 445
  • 1
  • 6
  • 22
0
votes
1 answer

Set strict sql mode in peewee

I'd like to force ENUM constraints in my mySQL database. To do that, it is suggested I use "strict" sql mode. In an interactive prompt, this can be set with one of: SET GLOBAL sql_mode = 'STRICT_ALL_TABLES'; SET SESSION sql_mode =…
isthisthat
  • 143
  • 1
  • 10