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
5
votes
2 answers

Python and Postgresql: OperationalError: fe_sendauth: no password supplied

I know there are a lot of similar questions on StackOverflow, but I have read and re-read them, and I cannot seem to solve my particular issue. I am developing a Python application that uses Peewee and Psycopg2 to access PostGresQL databases. This…
Becky S
  • 83
  • 1
  • 3
  • 6
5
votes
1 answer

Creating unique index with peewee for table with foreign key

Say that I have a table called TBL_ACCOUNT which contains all of my users, and a table called TBL_EMAIL_SUBSCRIPTION where it contains the feeds that a user is subscribed to. I'm trying to make it so that there can only be one entry of each…
Stupid.Fat.Cat
  • 10,755
  • 23
  • 83
  • 144
5
votes
4 answers

Python peewee save() doesn't work as expected

I'm inserting/updating objects into a MySQL database using the peewee ORM for Python. I have a model like this: class Person(Model): person_id = CharField(primary_key=True) name = CharField() I create the objects/rows with a loop, and each…
Martin Burch
  • 2,726
  • 4
  • 31
  • 59
5
votes
2 answers

Bulk insert with multiprocessing using peewee

I'm working on simple html scraper in Python 3.4, using peewee as ORM (great ORM btw!). My script takes a bunch of sites, extract necessary data and save them to the database, however every site is scraped in detached process, to improve performance…
Paweł Stysz
  • 53
  • 1
  • 4
5
votes
1 answer

How to use fn Object in Peewee ORM

I'm using Python's Peewee ORM to work with a MySQL database. Peewee supplies an object called "fn" that allows you to make certain types of calls to the database. One of those calls I want to make is the following: Blocks.select(Blocks,…
almel
  • 7,178
  • 13
  • 45
  • 58
5
votes
4 answers

Auto_increment custom Primary Key in Peewee model

I want a primary key id field to be Bigint class Tweets(Model): id = BigIntegerField(primary_key=True) ... But it needs to be auto_incremented and I can't find a way in the Peewee docs. Please suggest if it's possible. Update: I'm using…
Viacheslav
  • 3,876
  • 2
  • 21
  • 28
5
votes
1 answer

Why does the .count() return the wrong number on a peewee query with | (union)?

The first three queries below return the correct number, while the last one returns the wrong number. It should return 153, instead it returns 8193. I have no clue where that number comes from. Iterating through the query correctly returns 153…
stenci
  • 8,290
  • 14
  • 64
  • 104
5
votes
1 answer

Avoiding conflicting column titles in table join in peewee

I'm trying to join two tables in peewee with a mysql database. This is pretty easy doing something like this: s = Table1.select(Table1, Table2).join( Table2).naive().where(Table1.Title == "whatever") Unfortunately, I have called a column in…
Alex S
  • 4,726
  • 7
  • 39
  • 67
5
votes
1 answer

python peewee dynamically or clauses

I want to dynamically OR multiple clauses when performing a query. I see in the peewee documentation that: import operator or_clauses = reduce(operator.or_, clauses) # OR together all clauses However, this note is somewhat unclear. What exactly is…
Atul Bhatia
  • 1,633
  • 5
  • 25
  • 50
5
votes
2 answers

Concurrent writes with SQLite and Peewee

I'm planning to use SQLite and Peewee (ORM) for a light duty internal web service (<20 requests per second). The web service can handle multiple simultaneous requests on multiple threads. During each request the database will be both read from and…
stuckintheshuck
  • 2,449
  • 3
  • 27
  • 33
5
votes
1 answer

Python Flask: AttributeError: 'NoneType' object has no attribute 'is_active'

Using the Flask Mega Tutorial I'm trying to learn Flask. In part 5 of the tutorial I'm now building a profile page which needs the user to be logged in. Since I'm using the peewee ORM instead of SQLAlchemy, I do adjust the code here and there, but…
kramer65
  • 50,427
  • 120
  • 308
  • 488
5
votes
1 answer

AttributeError: 'SelectQuery' object has no attribute 'is_active'

I'm trying to learn the Peewee ORM in combination with Flask by following the Flask Mega Tutorial. In part 5 of the tutorial I create a login using OpenID. After overcoming a bunch of hurdles already I now get an AttributeError in the function…
kramer65
  • 50,427
  • 120
  • 308
  • 488
5
votes
1 answer

How to change UserDoesNotExist SELECT behavior in Flask-peewee - python & mysql

Im using flask-peewee to make an API and I'd like to return back a 404 json if user doesn't exist in the table but seems like it's throwing 500 error instead of 404 error json: Here is the Error I'm getting: UserDoesNotExist: instance matching…
Alireza Seifi
  • 135
  • 3
  • 11
5
votes
2 answers

Foreign key relationship with peewee and python

I'm trying to set up a database ORM with peewee and am not clear on the use of foreign key relationships. from peewee import * db = SqliteDatabase('datab.db') class datab(Model): class Meta: database = db class Collection(datab): …
Justin
  • 367
  • 1
  • 5
  • 15
5
votes
1 answer

Inserting into MySQL table using peewee raises "unknown column" exception

I have the following script: from peewee import * db = MySQLDatabase('database', user='root') class BaseModel(Model): class Meta: database = db class Locations(BaseModel): location_id = PrimaryKeyField() location_name =…
mangolier
  • 420
  • 4
  • 13