CREATE PROCEDURE `NewProc`(IN `groupID_` int,OUT `CountParam_` int)BEGIN set @CountParam_ = (select count(1) FROM mytable WHERE GroupID=groupID_ );END;
counts = bindparam('CountParam_',isoutparam=True,type_=Integer,value = 0)
connection = engine.raw_connection() try: cursor = connection.cursor() ss = cursor.callproc("QueryUsersByAuthorID", [user.groupID, counts]) results = list(cursor.fetchall())
print counts cursor.close() connection.commit() finally: connection.close()On Dec 15, 2014, at 4:53 AM, jichao liu <liujic...@gmail.com> wrote:procedure something like:CREATE PROCEDURE `NewProc`(IN `groupID_` int,OUT `CountParam_` int)BEGINset @CountParam_ = (select count(1) FROM mytable WHERE GroupID=groupID_ );END;
python:counts = bindparam('CountParam_',isoutparam=True,type_=Integer,value = 0)
connection = engine.raw_connection()try:cursor = connection.cursor()ss = cursor.callproc("QueryUsersByAuthorID", [user.groupID, counts])results = list(cursor.fetchall())
print countscursor.close()connection.commit()finally:connection.close()
why it always come out 0 for counts while results get the data?
ps. how to get the class obj results for the fetchall() other than tuple at now.
engine.execute(text('call QueryDataByGroupID(166012,:totalCount_);', bindparams = [outparam('totalCount_',type_= Integer)]))
(OperationalError) (1414, 'OUT or INOUT argument 2 for routine article_db.QueryDataByGroupID is not a variable or NEW pseudo-variable in BEFORE trigger') 'call QueryDataByGroupID(166012,,%s);' (None,)
recode_list = list(cursor.fetchall())description_index = [x[0] for x in cursor.description]data_list = [DictToObject(**dict(zip(description_index, each))) for each in recode_list]
class DictToObject: def __init__(self, **entries): self.__dict__.update(entries)