Get container record by ID. Args: container_id: Container ID to look up Returns: ContainerRecord if found, None otherwise
(self, container_id: str)
| 143 | conn.close() |
| 144 | |
| 145 | def get_by_id(self, container_id: str) -> Optional[ContainerRecord]: |
| 146 | """Get container record by ID. |
| 147 | |
| 148 | Args: |
| 149 | container_id: Container ID to look up |
| 150 | |
| 151 | Returns: |
| 152 | ContainerRecord if found, None otherwise |
| 153 | """ |
| 154 | conn = self._get_connection() |
| 155 | try: |
| 156 | cursor = conn.cursor() |
| 157 | cursor.execute( |
| 158 | "SELECT container_id, container_name, image_name, owner_pid, created_at, config_hash, platform_type FROM containers WHERE container_id = ?", |
| 159 | (container_id,), |
| 160 | ) |
| 161 | row = cursor.fetchone() |
| 162 | if row: |
| 163 | return ContainerRecord( |
| 164 | container_id=row[0], |
| 165 | container_name=row[1], |
| 166 | image_name=row[2], |
| 167 | owner_pid=row[3], |
| 168 | created_at=row[4], |
| 169 | config_hash=row[5] if len(row) > 5 else "", |
| 170 | platform_type=row[6] if len(row) > 6 else "", |
| 171 | ) |
| 172 | return None |
| 173 | finally: |
| 174 | conn.close() |
| 175 | |
| 176 | def insert( |
| 177 | self, |