Select with pyodbc

Asked

Viewed 208 times

0

I am trying to use the string I get from an Entry and Optionmenu to perform the Sqlserver search but from the following error:

TypeError: not enough arguments for format string

Here is the code of the function that executes the call:

def checkin(self):
    veri = self.cur.execute("select %s.id_aluno "
                            "from alunos,%s"
                            " where %s.id_aluno = alunos.matricula" % self.variavel.get() % self.variavel.get() % self.variavel.get() )
    print(veri)

1 answer

0


You should only wear one % after the string and pass a tuple:

def checkin(self):
    veri = self.cur.execute("select %s.id_aluno "
                            "from alunos,%s"
                            " where %s.id_aluno = alunos.matricula" % (self.variavel.get(), self.variavel.get(), self.variavel.get()) )
    print(veri)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.