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

Python Peewee - Incorporating Peewee into an Existing Database with Tables that Lack an ID AUTO_INCREMENT field

I have a table that records temperature data, which as 1.2 million rows in it. There is currently no primary key on it, although it has a candidate key. Since Peewee requires all tables have an ID AUTO_INCREMENT column, should I simply add one to…
Matthew Moisen
  • 16,701
  • 27
  • 128
  • 231
0
votes
1 answer

peewee python multiple foreign keys on table

I have the following model class: class Ticket(BaseModel): event = ForeignKeyField(Event) category = ForeignKeyField(Category) order_number = IntegerField() tier_name = CharField() num_available = IntegerField() price =…
Atul Bhatia
  • 1,633
  • 5
  • 25
  • 50
0
votes
1 answer

Illegal mixing of collation error utf8mb4 with peewee

I have a collation error with MySQL, specifically it is the following: OperationalError: (1267, "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='") After checking, I noticed that it is…
0
votes
2 answers

Counts on joined tables using Peewee

I'm trying to write a query using the Peewee ORM. The query should return all names of Users which have at least one message associated with them. I currently try this as follows: usersWithAtLeastOneMessage =…
kramer65
  • 50,427
  • 120
  • 308
  • 488
0
votes
1 answer

Peewee Python ORM: assign query result to ForeignKeyField

I have 2 models with a dead-simple one-to-many relationship. I'm trying to assign the result of querying one of them into the other entity, but I don't know how to do it. This is the code: The main class inherit from 2 classes, and has also the…
Alberto Fernández
  • 1,568
  • 13
  • 22
0
votes
2 answers

How to create tables for flask app using peewee orm without double quotes in postgresql

I'm new to peewee orm. Peewee uses double quotes when creating tables making it unnecessarily difficult to do select statements through psql shell. This goes for django's orm as well. What I really want is a simple: select username,password from…
user805981
  • 9,979
  • 8
  • 44
  • 64
0
votes
2 answers

How to filter a query in flask-peewee by URL?

I'd like to run the following query by flask-peewee, merchant_name LIKE 'seaside%' SELECT * FROM `merchant_details` WHERE `merchant_name` LIKE 'seaside%' Here is the return JSON of the below URL and I need to filter the merhcnat_name…
Alireza Seifi
  • 135
  • 3
  • 11
0
votes
1 answer

Peewee ORM gives IntegrityError: user_id may not be NULL

I'm trying to use the Peewee ORM for my new (Flask) website, and now I ran into a problem. I just created a simple model like so: from peewee import TextField, DateTimeField, IntegerField, ForeignKeyField from app import db ROLE_USER = 0 ROLE_ADMIN…
kramer65
  • 50,427
  • 120
  • 308
  • 488
0
votes
1 answer

Generate select with optgroup in Peewee

I have the following models in a flask application with the Peewee ORM: class Course(db.Model): name = CharField() class Activity(db.Model): course = ForeignKeyField(Course) name = CharField() I want to generate a multiple select…
Ben
  • 1,561
  • 4
  • 21
  • 33
0
votes
2 answers

Save a form in flask ?

i have code for form , i want to save the data through a form. custom form is :-
Brar Kirmal
  • 139
  • 1
  • 3
  • 18
0
votes
1 answer

create an app in flask-peewee

am trying to create an app for user registration , whenever i try to insert the values in the database tan it will display an error :- TypeError: object() takes no parameters. views.py @app.route('/join/' , methods=['GET','POST']) def join(): …
Ranjeet singh
  • 794
  • 1
  • 16
  • 38
0
votes
0 answers

creating an app in flask-peewee

i am creating an app in flask-peewee for user login , register and logout. all the app are route properly on the url. the problem is occur when i try to post the data than it give an error :- The server encountered an internal error and was unable…
Ranjeet singh
  • 794
  • 1
  • 16
  • 38
0
votes
0 answers

How to execute insert query and returns the new row's Primary Key

I've tried the flask-peewee / peewee example. the query runs sucessfully but It doesn't return the new row PK. Here is my code: @app.route('/api/merchant/invoice/', methods=['POST']) def merchantInvoice(): if request.method == 'POST' and…
Alireza Seifi
  • 135
  • 3
  • 11
0
votes
1 answer

How to customize Flask-peewee RESTfull api?

I'm newbie in flask and python, I would like to customize the flask-peewee restAPI to return the (latitude, longitude) instead of MerchantDetail.Address in JSON. I need to make more changes to API objects in place of getting values directly from…
Alireza Seifi
  • 135
  • 3
  • 11
0
votes
1 answer

using admin configuration in model file

The following code is working fine. run.py import datetime from flask import Flask from peewee import TextField, DateTimeField from flask_peewee.db import Database from flask_peewee.auth import Auth from flask_peewee.admin import Admin,…
beebek
  • 1,893
  • 5
  • 29
  • 33