doing wrong here?
def query(self, query: str, params: Tuple):
self.cursor.execute(query % params)
that is my function. I am trying to call it like this:
session.query("REVOKE CONNECT ON DATABASE %s FROM PUBLIC, crmpicco", (dbname))
but I am getting the following error:
TypeError: not all arguments converted during string formatting
(i'm on Python 3.9.6)
Don't use old style string formatting
The error must be because you're not passing a tuple as the second argument, you need to add a trailing comma before closing the parenthesis
Thanks for replying. do you mean I should be using f strings instead? What would you recommend?
Replace % into the function with , It's subject to sql injection this way
cursor.execute(query, params) Read from here: https://t.me/c/1111136772/179042
thanks, that helped
Обсуждают сегодня