0

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)

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.