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

Orphaned rows when using ManyToManyField?

I'll take the example from the docs to explain it. class Student(BaseModel): name = CharField() class Course(BaseModel): name = CharField() students = ManyToManyField(Student, related_name='courses') StudentCourse =…
Timo
  • 164
  • 2
  • 12
0
votes
3 answers

get_or_create: is it a 'get' or a 'create'?

AFAIK, peewee's Model.get_or_create() doesn't return a flag that indicates a creation, unlike django's get_or_create(). Is there a good way to check if an instance returned by get_or_create() is freshly created? Thanks
Kar
  • 6,063
  • 7
  • 53
  • 82
0
votes
2 answers

Two tables with foreign key referencing the other, NameError

I'm trying to create tables with foreign keys in database with peewee. Player table has ForeignKey to Team table and Team table has ForeignKey to Player table. When i run my code i'm getting NameError: name 'Team' is not defined Here is my…
KsaneK
  • 125
  • 1
  • 1
  • 5
0
votes
1 answer

Decipher Peewee ORM Postgres query error

I'm using Peewee in my Flask project. I have an ORM query which worked in SQLite, but is now causing an error as I'm migrating to Postgres. I wondered if anyone could help me diagnose it: stats = ( Assignment.select( Type.name, …
commadelimited
  • 5,656
  • 6
  • 41
  • 77
0
votes
2 answers

Proper way to use Peewee ORM Pooled Connection

I'm using the Peewee ORM in my Python WSGI web app. I've been having issues with the MySQL Server "going away", so I switched to the PooledMySQLDatabase. I will still having issues with the server going away after a few hours.. According to the…
mox1
  • 614
  • 3
  • 10
0
votes
0 answers

How to use the read and write with multithreading?

Good day. Please help me with a problem. I'm having trouble updating / reading data in a thread when using ORM. I've been using peewee for Python. After reading the documentation starting to initialize the object to work with the database. db =…
0
votes
1 answer

Explicitly return empty Peewee recordset

I'm running a query which accepts a search parameter. If the search parameter is ever empty I'd like to explicitly return an empty record set. There are a number of other cases in which it would be useful to return an empty recordset as well. I've…
commadelimited
  • 5,656
  • 6
  • 41
  • 77
0
votes
1 answer

Specifying Table to Connect to with Python Peewee

I have read the Peewee MySQL API documentation and this question; however, what I do not understand is how to connect to a specified table in a db using Peewee. Essentially all I'm trying to do is connect to a a table called Persons in a db called…
beckah
  • 1,543
  • 6
  • 28
  • 61
0
votes
1 answer

Reference to only one of multiple possible tables

I'm moving my poorly designed SQLite database to the Peewee ORM and having troubles finding a nice way for the following scenario. I have a DVD table to hold all information about the release itself and tw tables describing a DVD status. Both these…
Timo
  • 164
  • 2
  • 12
0
votes
1 answer

Using COLLATE on peewee queries

I found in the peewee documentation how to create custom collations, but I wasn't able to find how to use the built-in sqlite collating sequences. Ho do I create the following query in peewee (it is the last one in the above mentioned sqlite…
stenci
  • 8,290
  • 14
  • 64
  • 104
0
votes
0 answers

Running Flask app on Heroku

I'm trying to run a Flask app on Heroku and I'm getting some frustrating results. I'm not interested in the ops side of things. I just want to upload my code and have it run. Pushing to the Heroku git remote works fine (git push heroku master), but…
commadelimited
  • 5,656
  • 6
  • 41
  • 77
0
votes
1 answer

Does Peewee support Elasticsearch?

Simple question guys, I am pretty new to Elasticsearch and just got to know about the Peewee package, I am interested to know if Peewee supports elasticsearch as the product that I am working on requires support for a wide variety of data…
Amit P
  • 924
  • 2
  • 11
  • 15
0
votes
1 answer

Peewee Foreignkeyfield doesn't accept appropriate foreign key field

I'm using the Python Peewee ORM in my flask app as a database. I've got a user defined and a ticket as follows: class Ticket(db.Model): created = DateTimeField(default=datetime.utcnow) event_id = CharField() owner = ForeignKeyField(User,…
kramer65
  • 50,427
  • 120
  • 308
  • 488
0
votes
1 answer

Cherrypy + sqlite3 + Peewee crashes when two processes execute the same code at the same time

Navigating to the page test?x=a defined below it works. Navigating to test?x=a and then quickly navigating to test?x=b, both the cycles will keep running for a few seconds, but one of them will eventually crash with the error…
stenci
  • 8,290
  • 14
  • 64
  • 104
0
votes
1 answer

PeeWee: Ignores foreign key constraint

Job.select().where(Job.user == current_user.id and Job.status == "Running") Keeps returning the wrong row from the wrong user. It seems to ignore the statement Job.user == current_user.id altogether. I also…
user299709
  • 4,922
  • 10
  • 56
  • 88