Get container record by name. Args: container_name: Container name to look up Returns: ContainerRecord if found, None otherwise
(self, container_name: str)
| 112 | return sqlite3.connect(self.db_path, timeout=10.0) |
| 113 | |
| 114 | def get_by_name(self, container_name: str) -> Optional[ContainerRecord]: |
| 115 | """Get container record by name. |
| 116 | |
| 117 | Args: |
| 118 | container_name: Container name to look up |
| 119 | |
| 120 | Returns: |
| 121 | ContainerRecord if found, None otherwise |
| 122 | """ |
| 123 | conn = self._get_connection() |
| 124 | try: |
| 125 | cursor = conn.cursor() |
| 126 | cursor.execute( |
| 127 | "SELECT container_id, container_name, image_name, owner_pid, created_at, config_hash, platform_type FROM containers WHERE container_name = ?", |
| 128 | (container_name,), |
| 129 | ) |
| 130 | row = cursor.fetchone() |
| 131 | if row: |
| 132 | return ContainerRecord( |
| 133 | container_id=row[0], |
| 134 | container_name=row[1], |
| 135 | image_name=row[2], |
| 136 | owner_pid=row[3], |
| 137 | created_at=row[4], |
| 138 | config_hash=row[5] if len(row) > 5 else "", |
| 139 | platform_type=row[6] if len(row) > 6 else "", |
| 140 | ) |
| 141 | return None |
| 142 | finally: |
| 143 | conn.close() |
| 144 | |
| 145 | def get_by_id(self, container_id: str) -> Optional[ContainerRecord]: |
| 146 | """Get container record by ID. |