Here is the code snippet I attempted
query = tbl_scores.select().limit( bindparam('lim') )
However, I got the following error.
TypeError: int() argument must be a string or a number, not 'BindParameter'
Can anybody present an example of using bindparam for LIMIT/OFFSET?
Python 2.7.5, SQLAlchemy 0.8.4
Assume an webapi to return top players and their ranks. Construct an query with the bind parameter like this, then store it in a thread local place so that requests can share the same precompiled query.
# TypeError occurs here a_thread_local_place.query = join(tbl_scores, tbl_master_player, tbl_scores.c.uid == tbl_master_player ).\ select().limit(bindparam('lim'))
Everytime the webapi handles a request, I would like to execute the query like this using the precompiled query.
result = engine.connect().execute( a_thread_local_place.query, lim = 10, )