How can I convert a Panda DataFrame or QTableWidget to a Pdf?
I have my Sqlite3 database products listed in a QtableWidget (PyQt5) and have them also listed in a panda dataframe. How can I convert one of these to PDF?
I want to generate a product report and any of these methods would suit me. I tried a lot of things I saw on the stack and google but nothing worked.
DataFrame Function
def gerarRelatorio(self):
self.banco = sqlite3.connect ( 'Vendas.db' )
self.cursor = banco.cursor ( )
engine = create_engine('sqlite:///Vendas.db')
df = pd.read_sql_table("Produtos", engine)
print(df)
QtableWidget Function
def LoadDatabase(self):
self.banco = sqlite3.connect ( 'Vendas.db' )
self.cursor = banco.cursor ( )
query = "SELECT * FROM Produtos"
result = self.banco.execute ( query )
self.listaprodutos.setRowCount ( 0 )
for row_number, row_data in enumerate ( result ):
self.listaprodutos.insertRow ( row_number )
for colum_number, data in enumerate ( row_data ):
self.listaprodutos.setItem(row_number, colum_number, QtWidgets.QTableWidgetItem(str(data)))