Querying a MySQL database using tkinter variables
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:
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
add a comment |
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:
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
Are you sure you're getting a tuple back fromEditEvent.get()
? The docs indicate thatget()
returns a string.
– Will Keeling
Nov 19 '18 at 17:35
@WillKeeling It may be a string. When I doEvent.get()[4]
I gett
– MainStreet
Nov 19 '18 at 22:11
add a comment |
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:
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
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:
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
python mysql tkinter
asked Nov 19 '18 at 16:03
MainStreet
295
295
Are you sure you're getting a tuple back fromEditEvent.get()
? The docs indicate thatget()
returns a string.
– Will Keeling
Nov 19 '18 at 17:35
@WillKeeling It may be a string. When I doEvent.get()[4]
I gett
– MainStreet
Nov 19 '18 at 22:11
add a comment |
Are you sure you're getting a tuple back fromEditEvent.get()
? The docs indicate thatget()
returns a string.
– Will Keeling
Nov 19 '18 at 17:35
@WillKeeling It may be a string. When I doEvent.get()[4]
I gett
– 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
add a comment |
1 Answer
1
active
oldest
votes
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(), ))
This did not work :( I do believe thatEditEvent.get()
is a string, however when the SQL command is executed it returns no results, despite being give the correcteventname
– MainStreet
Nov 20 '18 at 19:25
OK so it sounds as though you're past the original problem ofcould 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 ofEditEvent
, 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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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(), ))
This did not work :( I do believe thatEditEvent.get()
is a string, however when the SQL command is executed it returns no results, despite being give the correcteventname
– MainStreet
Nov 20 '18 at 19:25
OK so it sounds as though you're past the original problem ofcould 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 ofEditEvent
, 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
add a comment |
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(), ))
This did not work :( I do believe thatEditEvent.get()
is a string, however when the SQL command is executed it returns no results, despite being give the correcteventname
– MainStreet
Nov 20 '18 at 19:25
OK so it sounds as though you're past the original problem ofcould 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 ofEditEvent
, 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
add a comment |
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(), ))
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(), ))
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 thatEditEvent.get()
is a string, however when the SQL command is executed it returns no results, despite being give the correcteventname
– MainStreet
Nov 20 '18 at 19:25
OK so it sounds as though you're past the original problem ofcould 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 ofEditEvent
, 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
add a comment |
This did not work :( I do believe thatEditEvent.get()
is a string, however when the SQL command is executed it returns no results, despite being give the correcteventname
– MainStreet
Nov 20 '18 at 19:25
OK so it sounds as though you're past the original problem ofcould 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 ofEditEvent
, 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Are you sure you're getting a tuple back from
EditEvent.get()
? The docs indicate thatget()
returns a string.– Will Keeling
Nov 19 '18 at 17:35
@WillKeeling It may be a string. When I do
Event.get()[4]
I gett
– MainStreet
Nov 19 '18 at 22:11