Hey Gang!
OK today I am having trouble with my transaction processing application implemented in python/MySQL. Here is some "working" testing code.
import psycopg2
from psycopg2 import Error
import binascii
from binascii import unhexlify
import mysql.connector as mysql
sql='''CREATE PROCEDURE testprocedure(OUT tacos INT)
BEGIN
show tables;
SET tacos := 1 ;
END'''
blank_connection_string = {
'user': 'someusername',
'password': 'daniwebisthebest',
'host': 'localhost',
'database': 'fundatabase',
'raise_on_warnings': True }
connection=mysql.connect(**blank_connection_string, autocommit=True)
cursor=connection.cursor()
cursor.execute(sql)
cursor.callproc("testprocedure", (0, ) )
for r in cursor.stored_results():
print(r)
results=r.fetchall()
print(results)
for result in results:
print(result)
cursor.execute("drop procedure testprocedure")
cursor.close( )
connection.close()
So it works in that everything that I can fit into a stored procedure certainly executes. But I'm getting nonsense as far as returning the variable "tacos" into any format that python can access. To wit, here is what I'm getting for script output:
MySQLCursorBuffered: (a result of CALL testprocedure(@_testpr..
[('sometable1',), ('funtablename',), ('othertable',)]
('sometable1',)
('funtablename',)
('othertable',)
In other words it seems to be doing a pretty solid job of returning the results that I DON'T need sent back to me, but is not returning the result of the actual SP that I need.
How do I resolve this?