(self, dict: &Py<PyDict>, vm: &VirtualMachine)
| 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) } |
no test coverage detected