A useful simple to use tool to turn your sql query into a beautiful report html table
Project description
Flask_SqlAlchemy_Report is an easy to use tool for generating html table from sql query.
The package contains single function named "generateFromSql" which accepts 11 arguments :
- session : SQLAlchemy session
- 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']
- 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 flask_sqlalchemy using pip :
pip install flask-sqlalchemy-report
Usage :
from flask_sqlalchemy_report import Reporter
@app.route('/listOfPersons', methods=['GET'])
def listOfPersons():
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"
headerRowBackgroundColor = '#ffeeee'
evenRowsBackgroundColor = '#ffeeff'
oddRowsBackgroundColor = '#ffffff'
return Reporter.generateFromSql(db.session, reportTitle, sqlQuery, columnsToBeSummarized,
"ltr", fontName, "Total Salary", True,
headerRowBackgroundColor, evenRowsBackgroundColor, oddRowsBackgroundColor
)
See More
Project details
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 flask_sqlalchemy_report-0.2.3.tar.gz
.
File metadata
- Download URL: flask_sqlalchemy_report-0.2.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8e2cb570d03888a301f1ef76c1f0d0937004a1e1d51fb37cc8d8ed47bb7a165 |
|
MD5 | a4bdee7a2483f29fb93d0154efee5431 |
|
BLAKE2b-256 | 2dc28c0a3d7ac65609bb366009f42db3c04c0a51614678d68b26614aa700162f |
File details
Details for the file flask_sqlalchemy_report-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: flask_sqlalchemy_report-0.2.3-py3-none-any.whl
- Upload date:
- Size: 4.1 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 | e105e81a8753783f0e7bfbbb69974141dab7d4aee74b00949be94a40efe6de07 |
|
MD5 | 3313d382fb20d40cf7217cb8e3635285 |
|
BLAKE2b-256 | 22ca81c0826fc125ea1b579ba4f3cbdaa2267012624a774bc0062ddbf869347d |