Querying a MySQL database using tkinter variables












1














I am trying to perform a query using the result form a tkinter option menu.



The defining of the Option menu is shown below:



EventToEditOptionMenu = tk.OptionMenu(EditEventsFrame,EditEvent,*EventList)
EventToEditOptionMenu.grid(row=2,column=2)


A typical example of what's contained in EditEvent is shown below:



('uytrds',)


I am unable to perform the SQL query successfully, yielding the error:



ValueError: Could not process parameters


Here is a screenshot of the table:



event Table



EventSQL=("SELECT eventname, startdate, enddate, starttime, endtime, cost, limits FROM events WHERE eventname=%s")
print(EditEvent.get())
mycursor.execute(EventSQL,EditEvent.get())
myresults=mycursor.fetchall()
print(myresults)









share|improve this question






















  • Are you sure you're getting a tuple back from EditEvent.get()? The docs indicate that get() returns a string.
    – Will Keeling
    Nov 19 '18 at 17:35










  • @WillKeeling It may be a string. When I do Event.get()[4] I get t
    – MainStreet
    Nov 19 '18 at 22:11
















1














I am trying to perform a query using the result form a tkinter option menu.



The defining of the Option menu is shown below:



EventToEditOptionMenu = tk.OptionMenu(EditEventsFrame,EditEvent,*EventList)
EventToEditOptionMenu.grid(row=2,column=2)


A typical example of what's contained in EditEvent is shown below:



('uytrds',)


I am unable to perform the SQL query successfully, yielding the error:



ValueError: Could not process parameters


Here is a screenshot of the table:



event Table



EventSQL=("SELECT eventname, startdate, enddate, starttime, endtime, cost, limits FROM events WHERE eventname=%s")
print(EditEvent.get())
mycursor.execute(EventSQL,EditEvent.get())
myresults=mycursor.fetchall()
print(myresults)









share|improve this question






















  • Are you sure you're getting a tuple back from EditEvent.get()? The docs indicate that get() returns a string.
    – Will Keeling
    Nov 19 '18 at 17:35










  • @WillKeeling It may be a string. When I do Event.get()[4] I get t
    – MainStreet
    Nov 19 '18 at 22:11














1












1








1







I am trying to perform a query using the result form a tkinter option menu.



The defining of the Option menu is shown below:



EventToEditOptionMenu = tk.OptionMenu(EditEventsFrame,EditEvent,*EventList)
EventToEditOptionMenu.grid(row=2,column=2)


A typical example of what's contained in EditEvent is shown below:



('uytrds',)


I am unable to perform the SQL query successfully, yielding the error:



ValueError: Could not process parameters


Here is a screenshot of the table:



event Table



EventSQL=("SELECT eventname, startdate, enddate, starttime, endtime, cost, limits FROM events WHERE eventname=%s")
print(EditEvent.get())
mycursor.execute(EventSQL,EditEvent.get())
myresults=mycursor.fetchall()
print(myresults)









share|improve this question













I am trying to perform a query using the result form a tkinter option menu.



The defining of the Option menu is shown below:



EventToEditOptionMenu = tk.OptionMenu(EditEventsFrame,EditEvent,*EventList)
EventToEditOptionMenu.grid(row=2,column=2)


A typical example of what's contained in EditEvent is shown below:



('uytrds',)


I am unable to perform the SQL query successfully, yielding the error:



ValueError: Could not process parameters


Here is a screenshot of the table:



event Table



EventSQL=("SELECT eventname, startdate, enddate, starttime, endtime, cost, limits FROM events WHERE eventname=%s")
print(EditEvent.get())
mycursor.execute(EventSQL,EditEvent.get())
myresults=mycursor.fetchall()
print(myresults)






python mysql tkinter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 16:03









MainStreet

295




295












  • Are you sure you're getting a tuple back from EditEvent.get()? The docs indicate that get() returns a string.
    – Will Keeling
    Nov 19 '18 at 17:35










  • @WillKeeling It may be a string. When I do Event.get()[4] I get t
    – MainStreet
    Nov 19 '18 at 22:11


















  • Are you sure you're getting a tuple back from EditEvent.get()? The docs indicate that get() returns a string.
    – Will Keeling
    Nov 19 '18 at 17:35










  • @WillKeeling It may be a string. When I do Event.get()[4] I get t
    – MainStreet
    Nov 19 '18 at 22:11
















Are you sure you're getting a tuple back from EditEvent.get()? The docs indicate that get() returns a string.
– Will Keeling
Nov 19 '18 at 17:35




Are you sure you're getting a tuple back from EditEvent.get()? The docs indicate that get() returns a string.
– Will Keeling
Nov 19 '18 at 17:35












@WillKeeling It may be a string. When I do Event.get()[4] I get t
– MainStreet
Nov 19 '18 at 22:11




@WillKeeling It may be a string. When I do Event.get()[4] I get t
– MainStreet
Nov 19 '18 at 22:11












1 Answer
1






active

oldest

votes


















0














Based on your comment, I suspect the issue is that you're passing a string as the second argument to mycursor.execute(), rather than a tuple containing a string.



Try wrapping the result of EditEvent.get() in a tuple before passing it:
For example:



mycursor.execute(EventSQL, (EditEvent.get(), ))





share|improve this answer























  • This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
    – MainStreet
    Nov 20 '18 at 19:25










  • OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
    – Will Keeling
    Nov 20 '18 at 20:27










  • Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
    – MainStreet
    Nov 22 '18 at 17:18











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378494%2fquerying-a-mysql-database-using-tkinter-variables%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Based on your comment, I suspect the issue is that you're passing a string as the second argument to mycursor.execute(), rather than a tuple containing a string.



Try wrapping the result of EditEvent.get() in a tuple before passing it:
For example:



mycursor.execute(EventSQL, (EditEvent.get(), ))





share|improve this answer























  • This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
    – MainStreet
    Nov 20 '18 at 19:25










  • OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
    – Will Keeling
    Nov 20 '18 at 20:27










  • Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
    – MainStreet
    Nov 22 '18 at 17:18
















0














Based on your comment, I suspect the issue is that you're passing a string as the second argument to mycursor.execute(), rather than a tuple containing a string.



Try wrapping the result of EditEvent.get() in a tuple before passing it:
For example:



mycursor.execute(EventSQL, (EditEvent.get(), ))





share|improve this answer























  • This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
    – MainStreet
    Nov 20 '18 at 19:25










  • OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
    – Will Keeling
    Nov 20 '18 at 20:27










  • Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
    – MainStreet
    Nov 22 '18 at 17:18














0












0








0






Based on your comment, I suspect the issue is that you're passing a string as the second argument to mycursor.execute(), rather than a tuple containing a string.



Try wrapping the result of EditEvent.get() in a tuple before passing it:
For example:



mycursor.execute(EventSQL, (EditEvent.get(), ))





share|improve this answer














Based on your comment, I suspect the issue is that you're passing a string as the second argument to mycursor.execute(), rather than a tuple containing a string.



Try wrapping the result of EditEvent.get() in a tuple before passing it:
For example:



mycursor.execute(EventSQL, (EditEvent.get(), ))






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 10:06









MainStreet

295




295










answered Nov 19 '18 at 22:28









Will Keeling

10.9k22330




10.9k22330












  • This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
    – MainStreet
    Nov 20 '18 at 19:25










  • OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
    – Will Keeling
    Nov 20 '18 at 20:27










  • Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
    – MainStreet
    Nov 22 '18 at 17:18


















  • This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
    – MainStreet
    Nov 20 '18 at 19:25










  • OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
    – Will Keeling
    Nov 20 '18 at 20:27










  • Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
    – MainStreet
    Nov 22 '18 at 17:18
















This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
– MainStreet
Nov 20 '18 at 19:25




This did not work :( I do believe that EditEvent.get() is a string, however when the SQL command is executed it returns no results, despite being give the correct eventname
– MainStreet
Nov 20 '18 at 19:25












OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
– Will Keeling
Nov 20 '18 at 20:27




OK so it sounds as though you're past the original problem of could not process parameters and now the SQL query is actually running, but just not matching anything. If you run the SQL query manually at the mysql command line with the value of EditEvent, does that produce any results?
– Will Keeling
Nov 20 '18 at 20:27












Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
– MainStreet
Nov 22 '18 at 17:18




Here is proof that the SQL syntax is correct. imgur.com/a/kbmTia7
– MainStreet
Nov 22 '18 at 17:18


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378494%2fquerying-a-mysql-database-using-tkinter-variables%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules