Skip to content

Expose statement bind parameters #627

@captn3m0

Description

@captn3m0

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:

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions