#🔒 str to tuple
13 messages · Page 1 of 1 (latest)
@fluid rose
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
send the code
search_entry = Entry(
win,
bd=2,
justify="center",
)
if search_entry.get() == "":
for row in DATA:
# print(test)
s2 = "{:^10}{:^55}{:^15}".format(
str(row[0]), row[1], row[2]
)
ls1.insert(END, s2)
for row_name in DATA:
name = row_name[1]
print("HELLOOOOO", name)
else:
db.search_item_admin(search_entry.get())
ls1.bind("<<ListboxSelect>>" , on_select)
#search_entry.bind("<Key>", db.search_item_admin(ti))
search_entry.place(x=150, y=350)
x = lambda:search(tuple(search_entry.get()))
search_button = Button(win,text = 'Search', width=8, bd = 2, fg = 'blue',command=x)
search_button.place(x = 350, y = 350)```
Hey @fluid rose!
It looks like you incorrectly specified a language for your code block.
Make sure you put your code on a new line following py. There must not be any spaces after py.
Here is an example of how it should look:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
def search(entry):
print("hello")
if entry == "":
showerror("Field Can't be empty")
else:
data = db.search_item_admin(entry)
print(data)
return data
def search_item_admin(self,name):
sql1 = "Select * from sandwiches where (description = '%s');"
self.cr.execute(sql1,(str(name)))
result = self.cr.fetchall()
print(result)
return result
configure the Entry widget with a StringVar to handle the entry text and make sure that the search function is called with the correct parameter
okay
I replaced all the .get with search_entry_var (Stringvar)
and still getting the same error
mysql.connector.errors.ProgrammingError: Could not process parameters: str(('B', 'u', 'r', 'g', 'e', 'r')), it must be of type list, tuple or dict```
as u told me before that it should be touple or list to read it from database so i added the tuple() to it but still getting str and in the tuple letters separated
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.