Nathan1995
Nathan1995

Reputation: 111

Creating HTML report from SQlite3 database in Python

I am currently using the code below to select certain information from an Sqlite3 database to give information back to the user. I am wondering if somebody could point me in the right direction to a library/function that can allow me to create an easy to read HTML report for the user rather than the standard terminal shown?

Kind regards.

connect = sqlite3.connect(sqlitedb)
with connect:
    cur = connect.cursor()
    cur.execute("""SELECT messages._id,messages.body, participants_info.number, participants_info.display_name, participants_info._id
        FROM messages
        INNER JOIN participants_info
        ON messages.participant_id = participants_info._id;""")
while True:

row = cur.fetchone()
if row == None:
    break
print (row)

Upvotes: 1

Views: 1422

Answers (1)

Nullman
Nullman

Reputation: 4279

i've never used it myself but, i know that pandas has a DataFrame.to_html method so what you can do is: import pandas as pd frame = pd.read_sql_query(your_query, sql_connection) frame.to_html() you can read this for specifics

Upvotes: 1

Related Questions