| 155 | |
| 156 | |
| 157 | class CLISessionDatabaseReader: |
| 158 | _READ_RECORD = """ |
| 159 | SELECT * |
| 160 | FROM session |
| 161 | WHERE key = ? |
| 162 | """ |
| 163 | _READ_HOST_ID = """ |
| 164 | SELECT id |
| 165 | FROM host_id |
| 166 | WHERE key = 0 |
| 167 | """ |
| 168 | |
| 169 | def __init__(self, connection): |
| 170 | self._connection = connection |
| 171 | |
| 172 | def read(self, key): |
| 173 | cursor = self._connection.execute(self._READ_RECORD, (key,)) |
| 174 | result = cursor.fetchone() |
| 175 | if result is None: |
| 176 | return |
| 177 | return CLISessionData(*result) |
| 178 | |
| 179 | def read_host_id(self): |
| 180 | cursor = self._connection.execute(self._READ_HOST_ID) |
| 181 | return cursor.fetchone()[0] |
| 182 | |
| 183 | |
| 184 | class CLISessionDatabaseSweeper: |
no outgoing calls