Python Forum
Python Stored Procedure call is not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Stored Procedure call is not working
#1
Code below does not work ? The mycursor.callproc("getclockinhoursbyweek",()) is the problem.


 mydb = mysqldb.connect(host="localhost", user="xxxxx",password="xxxx", db="xxx", use_unicode=True,charset="utf8")
        mycursor = mydb.cursor()
        mycursor.callproc("getclockinhoursbyweek",())
        myresult = mycursor.fetchall()
I have working code below and it returns data.
The difference in code above is that I am using stored procedure. "getclockinhoursbyweek"

mydb = mysqldb.connect(host="xxxxxx", user="xxxxxx",password="xxxxx", db="xxxxxxx", use_unicode=True,charset="utf8")
mycursor = mydb.cursor()
mycursor.execute("SELECT userid, username, userpassword FROM user")
myresult = mycursor.fetchall()
Reply
#2
(Apr-04-2021, 03:00 AM)vj78 Wrote: Code below does not work
what does this exactly mean? Do you get any error? What version of MySQL do you use?
Did you check compatibility note:
Quote:Compatibility note: It appears that the mere act of executing the CALL statement produces an empty result set, which appears after any result sets which might be generated by the stored procedure. Thus, you will always need to use nextset() to advance result sets.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Apr-04-2021, 07:33 AM)buran Wrote:
(Apr-04-2021, 03:00 AM)vj78 Wrote: Code below does not work
what does this exactly mean? Do you get any error? What version of MySQL do you use?
Did you check compatibility note:
Quote:Compatibility note: It appears that the mere act of executing the CALL statement produces an empty result set, which appears after any result sets which might be generated by the stored procedure. Thus, you will always need to use nextset() to advance result sets.

Code below does not work ? I am trying to call a stored procedure and that does not work.
Database MariaDB - version 10.4
I think mycursor.callproc("getclockinhoursbyweek",()) is the problem.
Error Message: No result set to fetch from
Reply
#4
It works now.

I had to look at this link and change my code:

for result in mycursor.stored_results():
myresult = result.fetchall()
Reply
#5
Please, don't edit your post AFTER you get a response. This breaks the flow of discussion - now my message seems incorrect after you added some error message. I reverted your latest edits.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(Apr-04-2021, 02:17 PM)buran Wrote: Please, don't edit your post AFTER you get a response. This breaks the flow of discussion - now my message seems incorrect after you added some error message. I reverted your latest edits.

Will do.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020