thanks for your reply,michael.
depart of the fucking '@' in my procedure, i try it by another way using
this:
engine.execute(text('call QueryDataByGroupID(166012,:totalCount_);',
bindparams = [outparam('totalCount_',type_= Integer)]))
but i get this error :
(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,)
finally i give up with the out param..
refer to the returning object, i figure out it using the attribute
*cursor.description,*although i hope it can return an instance in the
further:
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)
at last,forgive my pool english :D
On Monday, December 15, 2014 10:25:35 PM UTC+8, Michael Bayer wrote:
>
>
>
> On Dec 15, 2014, at 4:53 AM, jichao liu <[email protected] <javascript:>>
> wrote:
>
> procedure something like:
>
> CREATE PROCEDURE `NewProc`(IN `groupID_` int,OUT `CountParam_` int)
> BEGIN
> set @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 counts
> cursor.close()
> connection.commit()
> finally:
> connection.close()
>
> why it always come out 0 for counts while results get the data?
>
>
> no idea, that is the DBAPI cursor. Email the maintainers of MySQLdb, or
> whatever DBAPI it is that you’re using.
>
>
> ps. how to get the class obj results for the fetchall() other than tuple
> at now.
>
>
> you’d need to build a ResultProxy out of that cursor, then feed it into
> query.instances(). This might not be not very easy to do, so short of
> figuring out that, this feature is not supported right now.
>
>
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.