Select with pyodbc

0

I'm trying to use the string I get from an Entry and an OptionMenu to perform the search on SqlServer but gives the following error:

TypeError: not enough arguments for format string

Here is the function code 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)
    
asked by anonymous 18.04.2018 / 21:38

1 answer

0

You should only use % 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)
    
18.04.2018 / 23:11