Inserts a new search result into the searches table. Args: results: A dictionary containing search information. Returns: None
(self, search)
| 223 | return self.sdow_cursor |
| 224 | |
| 225 | def insert_result(self, search): |
| 226 | """Inserts a new search result into the searches table. |
| 227 | |
| 228 | Args: |
| 229 | results: A dictionary containing search information. |
| 230 | |
| 231 | Returns: |
| 232 | None |
| 233 | """ |
| 234 | paths_count = len(search['paths']) |
| 235 | |
| 236 | if paths_count == 0: |
| 237 | degrees_count = 'NULL' |
| 238 | else: |
| 239 | degrees_count = len(search['paths'][0]) - 1 |
| 240 | |
| 241 | # There is no need to escape the query parameters here since they are never user-defined. |
| 242 | query = 'INSERT INTO searches VALUES ({source_id}, {target_id}, {duration}, {degrees_count}, {paths_count}, CURRENT_TIMESTAMP);'.format( |
| 243 | source_id=search['source_id'], |
| 244 | target_id=search['target_id'], |
| 245 | duration=search['duration'], |
| 246 | degrees_count=degrees_count, |
| 247 | paths_count=paths_count, |
| 248 | ) |
| 249 | self.searches_conn.execute(query) |
| 250 | self.searches_conn.commit() |
no outgoing calls
no test coverage detected