you should use cursor.callproc() to call this stored procedure. See https://docs.sqlalchemy.org/en/latest/core/connections.html#calling-stored-procedures
On Mon, Jan 7, 2019 at 10:51 AM matthijs Blaauw <matthijsbla...@gmail.com> wrote: > > I made an MySQL Stored Procedure that is called updateplayerrank. It creates > a table called that computes a 'dense rank'. I want to store this rank into > the same table. > > DELIMITER $$ > CREATE DEFINER=`root`@`%` PROCEDURE `updateplayerrank`(IN gameidin int) > BEGIN > SET @prev_value = NULL; > SET @rank_count = 0; > UPDATE player AS p INNER JOIN > ((SELECT > id, > CASE > WHEN @prev_value = correct THEN @rank_count > WHEN @prev_value:=correct THEN @rank_count:=@rank_count + 1 > ELSE @rank_count:=@rank_count + 1 > END AS rank > FROM > player as x > WHERE > x.gameid = gameidin > ORDER BY correct DESC)) AS d > ON d.id = p.id > SET > p.ranked = d.rank > WHERE > p.gameid = gameidin; > END > $$ DELIMITER ; > > But when I run the stored the stored procedure created using the code above > with Flask-SQLAlchemy it returns the following error: > > (1052, "Column 'gameid' in where clause is ambiguous") > > Is there a way that I can stop the ambiguity error? Or is there a better > Query to do this operation. I am using MySQL version 5.7, so I don't have > acces to winnow functions. I am running the Stored procedure using the > following code: > > db.engine.execute("CALL updateplayerrank(%s)", (gameid)) > > I made the Stored Procedure With MySQLWorkbench and it runs fine over there. > I only get the error with Flask-SQLAlchemy > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.