Home > Back-end >  Not all parameters were used in the SQL statement in Python
Not all parameters were used in the SQL statement in Python

Time:10-21

I am a beginnner in mysql in Python. I would like to see all columns in my my_sheet_detail. I try this code:

import datetime as dt

class DatabaseConnector(MyConnector):
    def __init__(self):
        super(DatabaseConnector, self).__init__("mypage_cz")

    def load_positions(self, date: dt.date, manual: bool = False) -> List[Route]:
        query = f"""
            SELECT  *
            FROM `my_sheet_detail` 
            """
        self.cur.execute(query, (date,))
        data = self.cur.fetchall()
        return data


def show_positions():
    DATE = [(2019, 3, 8)]
    for day in DATE:
        date = dt.date(day[0], day[1], day[2])
        dbc = DatabaseConnector()
        routes = dbc.load_positions(date)
    print(routes)

But I get an error mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement. Can you help me please? What other parameters do I need? I just need to print the whole database my_sheet_detail.

CodePudding user response:

self.cur.execute(query, (date,))

Why are you sending the date as a parameter when it's not being used in the query? Remove it, it should work.

  • Related