Export Postgresql Table to excel with header in Python

My code works but it doesn’t bring the header with the names, it only brings the numbers 0 1 … 10 , what can I do ? Utils_db.py def consulta_sql(sql): try: connection = psycopg2.connect(user="postgres", password="postgres", host="localhost", port="5432", database="tb_cliente") cursor = connection.cursor() except (Exception, psycopg2.Error) as error: try: cursor.execute(sql) connection.commit() except (Exception, psycopg2.Error) as error: finally:… Read More Export Postgresql Table to excel with header in Python

Cutting Strings Pyhton

i have a simple ui created with pyqt5 it loads a file, let you choose a outputfolder and creats a new txt file with additonals information. the string of the loaded file is written to self.inputs.filename.text() it looks like "C:/User/Folder/File.txt" later in the application i write into a new file in a specific location. new_txt… Read More Cutting Strings Pyhton

How to get backgroud color of QtFrame in PyQt5?

I know how to set it: color_frame.setStyleSheet("QWidget { background-color: blue}") But how do I read the color value (may be in hex, I don’t care) of the QtFrame background ? Please note, I’m not looking for: color_frame.palette().highlight().color().name() since it doesn’t seem to ge me the value of QtFrame background color. >Solution : highlight() won’t give… Read More How to get backgroud color of QtFrame in PyQt5?

pyqt signal doesnt seem to work correctly with decorators

When using the pyqt signals of the UI elements such as buttons with decorated methods, the signal doesn’t seem to work. Please find below the minimum reproducible code. import sys from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication) from PyQt5.QtGui import QFont def ui_decorator(target_func): def call(self, *args, **kwargs): print("Init.") ret_code = target_func(self, *args, **kwargs) print("Deinit.") return… Read More pyqt signal doesnt seem to work correctly with decorators

Is it possible to shorten the code in PyQt5 by sticking lineEdit in for?

I have 7 lineEdit blocks, and I want the textChanged function to trigger when any of them change, I decided to take the easy route and write them out in order, but now I want to shorten my code. I wanna shorted this self.lineEdit_2.textChanged.connect(self.textChanged) self.lineEdit_3.textChanged.connect(self.textChanged) self.lineEdit_4.textChanged.connect(self.textChanged) self.lineEdit_5.textChanged.connect(self.textChanged) self.lineEdit_6.textChanged.connect(self.textChanged) self.lineEdit_7.textChanged.connect(self.textChanged) self.lineEdit_8.textChanged.connect(self.textChanged) like this for n in… Read More Is it possible to shorten the code in PyQt5 by sticking lineEdit in for?

Toggle button animation not working in PyQt?

I’m following a YouTube tutorial on creating animated toggle button. here is the code but it’s not working. I guess there is a problem with @property but I’m not sure. import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class ToggleButton(QCheckBox): def __init__(self, width = 70, bgColor = ‘#777’, circleColor… Read More Toggle button animation not working in PyQt?