2
I have a function that takes a postgresql database code and visualize setting in QLabel
with the function setText()
.
The problem is that this code comes from the database in strange format, between parentheses and comma. Example: (VI1,)
.
How to remove these commas and parentheses?
Function:
def cod_via(self,nome_via):
cursor = self.connectBanco()
sql = "SELECT cod_via FROM espacial.via WHERE nome_via = '%s'"%nome_via
cursor.execute(sql)
resultado = cursor.fetchall()
return resultado
Exhibit with:
cod = instancia_sql.cod_via(nome_via)
self.dlg.label_resul.setText(str(cod))
Staff solved. In addition to using fetchone() it is necessary to use Ope to traverse the result.
– Francisco Fabio
It looks like this: cursor.execute(sql) result = cursor.fetchone() for Resp in result: result=Resp; Return result
– Francisco Fabio