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

How do I connect to a MySQL Database in Python the right way?

update; hence to the kind and helpful replies of two great users here i did the following hello dear bryn many thanks i erased the db cpan and runned the programme again see the results: martin@linux-70ce:~/perl> python cpan_100.py Traceback (most…
user3730786
  • 45
  • 1
  • 7
0
votes
1 answer

Peewee says "cannot commit - no transaction is active"

My CherryPy app does some cleaning every hour with the following code: def every_hour(): two_hours_ago = time.time() - 2 * 60 * 60 DbChoice.delete().where(DbChoice.time_stamp < two_hours_ago).execute() monitor_every_hour =…
stenci
  • 8,290
  • 14
  • 64
  • 104
0
votes
0 answers

peewee regexp works only the first time

I'm running into an issue with the peewee regexp function. Queries like this work the first time I run it: query = Table.select().where(Table.column.regexp('string')) However, if I try to run it with a different string, I get this error: 'unicode'…
anonygrits
  • 1,459
  • 2
  • 14
  • 19
0
votes
0 answers

Flask app runs fine locally, but error accessing db on Heroku

I have a small Flask app (code below) that's basically just using peewee to access a Postgres database. It works fine when I run it locally, but I get a generic 500 Internal Server Error when I try to run it on Heroku. Here's the code from flask…
grautur
  • 29,955
  • 34
  • 93
  • 128
0
votes
1 answer

peewee migration "has no column named FOREIGN"

I'm trying to use peewee's migration module to rename a column from name to title in my page table. However I'm running this confusing error: peewee.OperationalError: table page__tmp__ has no column named FOREIGN My guess is that it has something…
csytan
  • 188
  • 2
  • 12
0
votes
1 answer

Peewee creates mutiple records (on flask app)

I have a simple statement, Points.create(user=bt.user,match=m,value=2,datecreated=date.today()) I expect it to create one record but sometimes it creates mutliple records. Not sure what's going on. Complete code is like below: from utils.models…
Aravind
  • 550
  • 7
  • 17
0
votes
1 answer

TTL with peewee

I feel a little strange asking this question, but I really have not been able to find an answer after pretty extensive googling. Right now I'm using the peewee ORM on top of PostgresQL and I'm implementing a password reset. For obvious reasons I…
Slater Victoroff
  • 21,376
  • 21
  • 85
  • 144
0
votes
1 answer

Is it possible to nest transactions in peewee + sqlite?

Executing the code below produces unexpected results. Is it a problem with peewee, sqlite, or my understanding of transactions? The code creates a transaction, then calls 3 times a function that creates 3 records in its own transaction. The function…
stenci
  • 8,290
  • 14
  • 64
  • 104
0
votes
1 answer

What would be the optimal schema for this relationship?

Basically a worker reads a queue of rows. I create a table called Work . A worker takes a row (work), it contains several tasks. Each task has several properties. Is this essentially a Work table with has_many relationship to a Task table holding…
KJW
  • 15,035
  • 47
  • 137
  • 243
0
votes
0 answers

OperationalError: Database is locked in Sqlite3 with peewee

There is foreign relationship between ExtensionData and DailyData. I read the ID of ExtensionData to input this into DailyData. But I'm greeted with an OperationalError database is locked when I do it like this. How do I avoid that? def…
Jonathan
  • 8,453
  • 9
  • 51
  • 74
0
votes
1 answer

PeeWee: select() always repeats first two rows

ids = "1,2,3,4" idlist = [int(i) for i in ids.split(',')] # [4, 1, 2, 3] jobs = Job.select().join(User).distinct().where(Job.id << idlist).dicts() if (jobs.count()): for i, job in enumerate(jobs): print str(i) + " : " +…
KJW
  • 15,035
  • 47
  • 137
  • 243
0
votes
1 answer

Peewee ORM get similar entries based on foreign key

I'm having problem with writing query for getting similar posts in a blog based on tags they have. I have following models: class Articles(BaseModel): name = CharField() ... class Tags(BaseModel): name = CharField() class…
Konrad Wąsowicz
  • 422
  • 2
  • 6
  • 12
0
votes
2 answers

Python Datetime error

This is part of my code. My imports: import jinja2 from jinja2 import evalcontextfilter, Markup, escape import os import hashlib import logging import json import re import webapp2 from string import * import random import hmac import xlwt from…
Jesus Benavent
  • 173
  • 1
  • 10
0
votes
1 answer

Updating dynamically determined fields with peewee

I have a peewee model like the following: class Parrot(Model): is_alive = BooleanField() bought = DateField() color = CharField() name = CharField() id = IntegerField() I get this data from the user and look for the…
P_S
  • 325
  • 1
  • 3
  • 16
0
votes
1 answer

Getting all rows through peewee based on foreign key

I currently have two peewee models "User" and "Game". Every Game can have many users and they are related by a ForeignKeyField in User. I'm simply trying fetch all users with a certain game id but I haven't been able to figure out how. So far I've…
shoopdelang
  • 985
  • 2
  • 9
  • 20