tortoise / tortoise/tortoise-orm

How to emulate such a request through Tortoise ORM?

Open
#418 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation enhancement Next Release
Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Hello, how I can a similar SQL request be sampled via Tortoise ORM? Read the documentation, but it doesn’t give examples of working with date and time

SELECT uid, SUM(posts) AS post, SUM(fine) AS fines, date FROM statistic
WHERE date > DATE(date) <= NOW() AND date >= DATE_SUB(NOW(), INTERVAL 31 DAY)
GROUP BY uid ORDER BY post DESC

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file, test, or entry point; it only provides a SQL query and asks how to express it through Tortoise ORM. Start by locating the documentation covering date/time filters, aggregation, grouping, ordering, and raw expressions. Done means adding a working example that represents the requested query and explaining its date boundaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
databases
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.