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
.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0