[![Downloads](https://static.pepy.tech/personalized-badge/django-query-to-table?period=total&units=international_system&left_color=black&right_color=green&left_text=Downloads)](https://pepy.tech/project/django-query-to-table)
### 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](https://mshaeri.com/blog/generate-html-table-report-from-sql-query-in-django/)
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 :
```shell
pip install django-query-to-table
```
## Usage :
```python
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)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/birddevelper/django-query-to-table",
"name": "django-query-to-table",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Django,Report,HTML,Table,SQL",
"author": "M.Shaeri",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/0b/6f/ce8e340af51db5e74bc7d7b3d340565e5636a603114d7bf08bda8b3fa5af/django-query-to-table-0.1.9.tar.gz",
"platform": null,
"description": "[![Downloads](https://static.pepy.tech/personalized-badge/django-query-to-table?period=total&units=international_system&left_color=black&right_color=green&left_text=Downloads)](https://pepy.tech/project/django-query-to-table)\n\n### django-query-to-table is an easy to use django package to generate html table from sql query.\n\nYou can read more about this package here : [django query to table](https://mshaeri.com/blog/generate-html-table-report-from-sql-query-in-django/)\n\nThe package contains one function named \"generateFromSql\" accepting 12 arguments :\n\n* cursor : DB cursor\n* title : The title of the report that will be shown on top of table\n* sqltext : The sql select query to retrieve data\n* footerCols : A list of columns name that you want to have Sum of values on footer . Example : ['amount','price']\n* htmlClass : Html CSS classes for the table\n* direction (default = \"ltr\") : Indicates direction of the report page. \"ltr\"- Left to Right , \"rtl\" - Right to Left\n* font (default = \"Tahoma\") : Font of title and table contents\n* totalText (default = \"Total\") : Title of footer row that will be the put below the first column.\n* rowIndex (default = False) : Indicates whether the table should have index column or not.\n* headerRowColor (default = '#eeeeee') : The header (title) row background color.\n* evenRowColor (default = '#ffffff') : The even rows background color.\n* oddRowColor (default = '#ffffff') : The odd rows background color.\n\n\n\n## Installation\nTo install django-query-to-table using pip :\n\n```shell\npip install django-query-to-table\n```\n\n## Usage :\n\n\n```python\nfrom django.db import connection\nfrom django_query_to_table import DjangoQtt\nfrom django.http import HttpResponse\n\n# view function in Django project\ndef listOfPersons(request):\n cursor = connection.cursor()\n reportTitle = \"Employee List\"\n sqlQuery = \"SELECT FirstName as 'First Name', LastName as 'Last Name', phone as 'Phone Number', salary as 'Salary' FROM persons\"\n columnsToBeSummarized = ['Salary']\n fontName = \"Arial\"\n cssClasses = \"reportTable container\"\n headerRowBackgroundColor = '#ffeeee'\n evenRowsBackgroundColor = '#ffeeff'\n oddRowsBackgroundColor = '#ffffff'\n table = DjangoQtt.generateFromSql(cursor, reportTitle, sqlQuery, columnsToBeSummarized, cssClasses,\n \"ltr\", fontName, \"Total Salary\", True,\n headerRowBackgroundColor, evenRowsBackgroundColor, oddRowsBackgroundColor\n )\n # table is a string variable contianing the html table showing the query result\n\n return HttpResponse(table)\n \n ```\n\n",
"bugtrack_url": null,
"license": "GNU",
"summary": "A simple to use Django package to turn your sql query into a beautiful reporting html table",
"version": "0.1.9",
"split_keywords": [
"django",
"report",
"html",
"table",
"sql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "64cffa4cd21514486f92a0444d771e29923c097650ba189ddf3d720a2432580f",
"md5": "a5407ec192a24eff6b1359d19c97a69b",
"sha256": "78a2abafa7a561cb5238c879f41659e9fac41e688f9ae828c4fdafc50b7a78d9"
},
"downloads": -1,
"filename": "django_query_to_table-0.1.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a5407ec192a24eff6b1359d19c97a69b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4387,
"upload_time": "2023-03-26T07:55:25",
"upload_time_iso_8601": "2023-03-26T07:55:25.091399Z",
"url": "https://files.pythonhosted.org/packages/64/cf/fa4cd21514486f92a0444d771e29923c097650ba189ddf3d720a2432580f/django_query_to_table-0.1.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0b6fce8e340af51db5e74bc7d7b3d340565e5636a603114d7bf08bda8b3fa5af",
"md5": "3b54977b88ab701c4992cab10af800f2",
"sha256": "253e9abfa63e593b2ae6f4f8d6e2cbacce2b31df269cdd8fb07bea9384d3ef4e"
},
"downloads": -1,
"filename": "django-query-to-table-0.1.9.tar.gz",
"has_sig": false,
"md5_digest": "3b54977b88ab701c4992cab10af800f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3857,
"upload_time": "2023-03-26T07:55:26",
"upload_time_iso_8601": "2023-03-26T07:55:26.648413Z",
"url": "https://files.pythonhosted.org/packages/0b/6f/ce8e340af51db5e74bc7d7b3d340565e5636a603114d7bf08bda8b3fa5af/django-query-to-table-0.1.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-26 07:55:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "birddevelper",
"github_project": "django-query-to-table",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-query-to-table"
}