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
-1
votes
1 answer

Formatting columns in peewee

I use Postgres, python3 and peewee. In the query below I have two column results that would help me a lot. select hrreference::time(0), to_char(hrreference, 'HH24:MI:SS.US') from wshop.documen How do I get any of these columns using peewee…
-1
votes
2 answers

How to make distinct via peewee in the python language?

I have a table in the sqlite with column "telegram_id" I want to get all unique records of this column def get_all_telegram_ids(): '''Returns all telegram_id from DB''' #rows = cursor.execute("SELECT DISTINCT telegram_id FROM…
-1
votes
1 answer

Convert SQL query to peewee

I need convert a SQL query to peewee instructions. My SQL is: parts_test = db.execute(''' SELECT tokenID, rewardCount FROM Loot INNER JOIN Quests ON Loot.questID = Quests.questID INNER JOIN Rewards ON Loot.rewardID =…
-1
votes
3 answers

Dynamic self join

Consider the following model, consisting of one table cars with 3 columns: class Car(Model): owner_id = IntegerField() name = CharField() power = IntegerField() The input can be from 1 up to 5 car names (no duplicates). How do you get…
vault
  • 3,930
  • 1
  • 35
  • 46
-1
votes
1 answer

Peewee auth failure

I'm trying to connect my application to postgresql database through peewee. config.ini: [DEFAULT] discord_key = apikey # private token from discord developer porter psql_user = postgres # username for postgres database psql_db = test # database…
Ken Adams
  • 83
  • 2
  • 9
-1
votes
1 answer

Why cant i read my database from my Flask app with peewee

I'm new to working with Flask and SQL, I am trying to create a simple front-end interface to deal with my database, I am using peewee as my ORM. This is my code: ``` def search(term): items = Product.select().where(Product.name == term) …
-1
votes
1 answer

Create subquery using peewee, using `.select` on the subquery results

I have a rather complex peewee query that looks like that: SolutionAlias = Solution.alias() fields = [ SolutionAlias.id.alias('solution_id'), SolutionAlias.solver.id.alias('solver_id'), …
Yam Mesicka
  • 6,243
  • 7
  • 45
  • 64
-1
votes
1 answer

sql how to get models sorted by foreign key amount field of last month

I had 2 tables User and Product for user id for product id amount - price of this product user_id - foreign key created - date of creating product i need to get list of Users sorted by sum of amounts of their products that they…
Brave
  • 21
  • 7
-1
votes
1 answer

AttributeError: 'MySQLDatabase' object has no attribute 'create_table'

I am trying to connect to MySQL database and create a table: import MySQLdb as mdb from peewee import * con = mdb.connect(host='127.0.0.1', user=db_user, db=db_name, passwd=db_pass) database = MySQLDatabase(db_name, user=db_user,…
kilich
  • 3
  • 2
-1
votes
1 answer

peewee filter with BinaryJSONField?

class Modex(baseModal): sdgdList = BinaryJSONField(verbose_name="sdgdList",null=True,) sdgdList Data: [{"x": "1", "cgs": "11.00", "gbxz": "A", "gdmc": "aaa", "zjqk": "0.48", "zzgs": "0.18", "zjqkCss": "red", "gdblockid": "10",}, {"x": "2",…
ccc
  • 3
  • 2
-1
votes
1 answer

'Expression' object has no attribute 'seconds'

I try get data with creation time more 60 mins. But its show error. How correct substract data? hour = datetime.datetime.now() - datetime.timedelta(minutes = 60) zayavkis =Zayavki.select().where(Zayavki.req_data-hour).seconds/60>60)
user1088259
  • 345
  • 13
  • 34
-1
votes
1 answer

How to use Peewee with multiprocessing, without "Commands out of sync; you can't run this command now" exception?

I write a large multi-process application and use Peewee as ORM, but when multiple processes try to access the database at the same time I get a synchronization error. How can I fix this problem without changing the application structure? Short code…
-1
votes
1 answer

How to use SELECT query based on method parameter in Flask restplus Api?

I want to handle a GET request in my Flask REST API.The request will include List parameter and I use this to be a typical GET request: https://localhost:5000/organisation?List=1 this request, will return all of Organisation Model information.…
mina
  • 153
  • 6
  • 18
-1
votes
1 answer

Apache running Flask on gcloud 500 Internal Server Error

I have been trying to deploy my flask app on an apache web sever and have gotten it to somewhat function. I am now facing the issue that the only page on which I need to either create a new entry in my database (using peewee sqlite for all things…
Bajjjjj
  • 50
  • 10
-1
votes
1 answer

Peewee: getting records where a given string startswith() the content of a field

I was writing a statement containing this where-clause in peewee: .where(some_string.startswith(Record.text_field)) This expression raises TypeError: startswith first arg must be str or a tuple of str, not CharField. some_string is just a normal…
Max Tet
  • 735
  • 1
  • 8
  • 16