MCPcopy Index your code
hub / github.com/RustPython/RustPython / bind_parameters_name

Method bind_parameters_name

crates/stdlib/src/_sqlite3.rs:3134–3158  ·  view source on GitHub ↗
(self, dict: &Py<PyDict>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

3132 }
3133
3134 fn bind_parameters_name(self, dict: &Py<PyDict>, vm: &VirtualMachine) -> PyResult<()> {
3135 let num_needed = unsafe { sqlite3_bind_parameter_count(self.st) };
3136
3137 for i in 1..=num_needed {
3138 let name = unsafe { sqlite3_bind_parameter_name(self.st, i) };
3139 if name.is_null() {
3140 return Err(new_programming_error(vm, "Binding {} has no name, but you supplied a dictionary (which has only names).".to_owned()));
3141 }
3142 let name = unsafe { name.add(1) };
3143 let name = ptr_to_str(name, vm)?;
3144
3145 let val = match dict.get_item_opt(name, vm)? {
3146 Some(val) => val,
3147 None => {
3148 return Err(new_programming_error(
3149 vm,
3150 format!("You did not supply a value for binding parameter :{name}.",),
3151 ));
3152 }
3153 };
3154
3155 self.bind_parameter(i, &val, vm)?;
3156 }
3157 Ok(())
3158 }
3159
3160 fn bind_parameter_count(self) -> c_int {
3161 unsafe { sqlite3_bind_parameter_count(self.st) }

Callers 1

bind_parametersMethod · 0.80

Calls 6

ptr_to_strFunction · 0.85
get_item_optMethod · 0.80
bind_parameterMethod · 0.80
ErrClass · 0.50
to_ownedMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected