A simple to use Django package to turn your sql query into a beautiful reporting html table
Project description
django-query-to-table is an easy to use django package to generate html table from sql query.
You can read more about this package here : django query to table
The package contains one function named "generateFromSql" accepting 12 arguments :
- cursor : DB cursor
- title : The title of the report that will be shown on top of table
- sqltext : The sql select query to retrieve data
- footerCols : A list of columns name that you want to have Sum of values on footer . Example : ['amount','price']
- htmlClass : Html CSS classes for the table
- direction (default = "ltr") : Indicates direction of the report page. "ltr"- Left to Right , "rtl" - Right to Left
- font (default = "Tahoma") : Font of title and table contents
- totalText (default = "Total") : Title of footer row that will be the put below the first column.
- rowIndex (default = False) : Indicates whether the table should have index column or not.
- headerRowColor (default = '#eeeeee') : The header (title) row background color.
- evenRowColor (default = '#ffffff') : The even rows background color.
- oddRowColor (default = '#ffffff') : The odd rows background color.
Installation
To install django-query-to-table using pip :
pip install django-query-to-table
Usage :
from django.db import connection
from django_query_to_table import DjangoQtt
from django.http import HttpResponse
# view function in Django project
def listOfPersons(request):
cursor = connection.cursor()
reportTitle = "Employee List"
sqlQuery = "SELECT FirstName as 'First Name', LastName as 'Last Name', phone as 'Phone Number', salary as 'Salary' FROM persons"
columnsToBeSummarized = ['Salary']
fontName = "Arial"
cssClasses = "reportTable container"
headerRowBackgroundColor = '#ffeeee'
evenRowsBackgroundColor = '#ffeeff'
oddRowsBackgroundColor = '#ffffff'
table = DjangoQtt.generateFromSql(cursor, reportTitle, sqlQuery, columnsToBeSummarized, cssClasses,
"ltr", fontName, "Total Salary", True,
headerRowBackgroundColor, evenRowsBackgroundColor, oddRowsBackgroundColor
)
# table is a string variable contianing the html table showing the query result
return HttpResponse(table)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-query-to-table-0.1.9.tar.gz
.
File metadata
- Download URL: django-query-to-table-0.1.9.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 253e9abfa63e593b2ae6f4f8d6e2cbacce2b31df269cdd8fb07bea9384d3ef4e |
|
MD5 | 3b54977b88ab701c4992cab10af800f2 |
|
BLAKE2b-256 | 0b6fce8e340af51db5e74bc7d7b3d340565e5636a603114d7bf08bda8b3fa5af |
File details
Details for the file django_query_to_table-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: django_query_to_table-0.1.9-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78a2abafa7a561cb5238c879f41659e9fac41e688f9ae828c4fdafc50b7a78d9 |
|
MD5 | a5407ec192a24eff6b1359d19c97a69b |
|
BLAKE2b-256 | 64cffa4cd21514486f92a0444d771e29923c097650ba189ddf3d720a2432580f |