-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
For a given prepared statement, it should be possible to fetch the list of parameters that can be bound to it.
The 3 relevant SQLite methods are:
- https://sqlite.org/c3ref/bind_parameter_count.html
- https://sqlite.org/c3ref/bind_parameter_name.html
- https://sqlite.org/c3ref/bind_parameter_index.html
Without these 3, if you are processing parameters on configurable queries, it is hard to bind only stuff that's needed.
For a specific usecase, I do the following in my Jekyll-SQLite extension:
##
# Prepare the query by binding the parameters
# Since we don't know if the query needs them
# we ignore all errors about "no such bind parameter"
def _prepare_query(stmt, params)
params.each do |key, value|
stmt.bind_param key, value
rescue StandardError => e
raise e unless e.message.include? "no such bind parameter"
end
end
params is a dict, but because it is inherited from Jekyll's page data structure, it can contain keys that are not required by the query (such as title
). So we check the exception and ignore for now.
Metadata
Metadata
Assignees
Labels
No labels