0
When running the code below I get the title error, I tried to use a different code structure by assigning the results of select to a ma variable, tried tbm just bring a bank line with fetchone() and unfortunately I haven’t succeeded in trying.
import pyodbc import pymysql import the
Important class Bank: def init(self): self.server = 'localhost' self.database = 'lc_firmas' self.username = 'root' self.password = 'little girl' self.port = '3306' self.string_connection = pyodbc.connect( 'DRIVER={Devart ODBC Driver for Mysql};User ID='+self.username+';Password='+self.password+';Server='+self.server+';Database='+self.database+';Port='+self.port+';String Types=Unicode') self.connection = self.string_connection.cursor()
def gravarselos_aut(self):
self.query = 'SELECT data, letra, NumIni, Numfin FROM selosaut'
self.conexao.execute(self.query)
resultado = conexao.fetchall()
for linha in resultado:
self.data = str(self.conexao.fetchall([0]))
self.letra = str(self.conexao.fetchall([1]))
self.Num_Inicial = str(self.conexao.fetchall([2]))
self.Num_Fin = str(self.conexao.fetchall([3]))
print(
f'{linha} {self.data}, {self.letra}, {self.Num_Inicial}, {self.Num_Fin}')
The mistake says
fetchall
does not take arguments. In your code you are passing an argument. You have tried to change thisself.conexao.fetchall([0])
forlinha[0]
?– Andre