Python Forum
[Tkinter] load sqlite3 data into pdf
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] load sqlite3 data into pdf
#1
Hi,

I searched for code sample to learn how to put one of my db. table fields into pdf with many pages. Is there any tutorials out there that teaches how to deal with that, I heard about the reportlab library but I didn't find something dealing with sqlite3 tables.

I am trying to generate an exam report for students so I am taking the data from a table that holds all the candidate info, the questions, the answers, the student answer and the correct answer with total of marking and a pass or fail.

Thanks.
Reply
#2
use pandas.
Here's an example: https://newbedev.com/export-pandas-dataf...ing-python
rwahdan likes this post
Reply
#3
(Jul-23-2021, 07:58 PM)Larz60+ Wrote: use pandas.
Here's an example: https://newbedev.com/export-pandas-dataf...ing-python
Thank you very much this worked for me. Now, I have created the pdf and it is saved in the same directory. Is there a way to add button that can ask the user to save that same file to destination like save as?
Reply
#4
https://docs.python.org/3/library/dialog...filedialog Wrote:The tkinter.filedialog module provides classes and factory functions for creating file/directory selection windows.
Reply
#5
I did use the dialog like this:
        saveFilePath = filedialog.asksaveasfile(mode='w', title="Save the file", defaultextension=".pdf",
                        initialfile=pdf_file_name, filetypes=(("PDF Files", "*.pdf"),))

        saveFilePath.close()
and I am able to save as pdf but when trying to open it, it says it is not type of pdf. In the project directory the file is opening though. I think this will only have a default name of saving a file but not choosing the file that I want to save.
I found a solution that suits me. the pdf will open after it is created then the user can choose to save it.
subprocess.Popen([pdf_file_name], shell=True)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PyQt5 form not displaying my data from SQLite3 Database Linuxdesire 1 2,678 Dec-09-2019, 02:49 PM
Last Post: Denni
  [Tkinter] I need to know how to put my SQLite3 data into a Treeview Thename921 1 4,342 Jan-12-2019, 10:26 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020