0
Please help, my class does not connect in Access at all.. I’m using: Pycharm, win10 (x64), office 2007 and 2016, python 3.6(x86). Thank you for your attention. follows example of the class:
class Banco(object):
def __init__(self):
conStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=D:\BDFone\AgMesaIB.mdb"
conxn = pyodbc.connect(conStr)
self.cursor = conxn.cursor()
class Cadastro(object):
def __init__(self, controle="", nome="", nome2="", email="", telefone=""):
self.info = {}
self.cod = controle
self.nome = nome
self.nome2 = nome2
self.email = email
self.telefone = telefone
def selectCad(self, pnome):
banco = Banco()
try:
c = banco.cursor()
c.execute("select * from Geral WHERE Primeiro_nome='" + pnome + "'")
for linha in c:
self.cod = linha[0]
self.nome = linha[1]
self.nome2 = linha[2]
self.email = linha[3]
self.telefone = linha[4]
c.close()
return "Busca feita com sucesso!"
except:
return "Ocorreu um erro na busca do Cadastro"
How do you know it doesn’t connect?
– Woss
Because it returns the except error "An error occurred in the Register search"
– Denis Lougon
So you can, instead of just using
except
, doexcept Exception as e
and putreturn e
, so you’ll have exactly the error message and not a generic one that tells you nothing about the error.– Woss
Follow its orientation and it worked. displayed the following error: 'pyodbc.Cursor' Object is not callabe
– Denis Lougon