I am trying to export a list of sqlite table in pdf with pandas and reportlab. When I print everything looks good, but when I try to generate pdf I get only headers row but as column format. Because is part of larger application I have a little GUI to generate pdf. Any help will be appreciated. Thanks
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Pdf_test")
self.grid()
self.label = Label(self.parent, text = 'Pdf test')
self.label.grid(row=0, column=0)
self.buton = Button(self.parent, width= 15, text=" PDF ", command=self.pdf_test)
self.buton.grid(row=1, column=0)
def pdf_test(self):
self.conn = sqlite3.connect("Baza_Date.db")
self.cursor = self.conn.cursor()
with self.conn:
self.cursor.execute("SELECT * FROM test1")
rows = (pd.read_sql_query("SELECT * FROM test1", self.conn))
print (rows)
report = canvas.Canvas("Multi.pdf") # save pdf in working folder)
report.setFont("Times-Roman", 20)
report.setFillColor(black)
size = 9
y = 650
for row in rows:
report.setFont("Helvetica", size)
report.drawString(70, y, row)
y = y - 10
report.save()