1234567891011121314151617181920212223242526272829303132 |
- from django.db import connection
- class Query:
- #@staticmethod
- def sql_query(method):
- def wrapper():
- with connection.cursor() as cursor:
- method(cursor)
- return wrapper
- @sql_query
- #@staticmethod
- def get_tickets(cursor):
- cursor.execute("""
- SELECT
- tickets_task.id,
- tickets_task.title,
- SharixAdmin_sharixuser.username,
- tickets_task.created_by_id,
- tickets_task.priority
- FROM
- tickets_task
- JOIN
- SharixAdmin_sharixuser
- ON
- tickets_task.created_by_id == SharixAdmin_sharixuser.id
- ORDER BY
- tickets_task.priority;
- """)
- rows = cursor.fetchall()
- print(rows)
|