I have a function that is being used with 2 optional parameters offset and limit :
query = db.engine.execute(sql, offset=pagination.offset, limit=pagination.limit)
Is there a way I can pass it a list of dynamic parameters? Something like this:
db.engine.execute(sql, param_obj)
You can build the optional parameters as a dict
and pass it to the function
param_obj = dict(offset=pagination.offset, limit=pagination.limit)
db.engine.execute(sql, **param_obj)
Or if you really want to pass the optional paraemters as list, you can, but care should be taken to ensure the order of parameters being passed
param_obj = [pagination.offset, pagination.limit]
db.engine.execute(sql, *param_obj)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.