Initialize async engine and create tables.
(self)
| 55 | self._read_method = self._read_fifo |
| 56 | |
| 57 | async def prepare(self) -> None: |
| 58 | """Initialize async engine and create tables.""" |
| 59 | if self._initialized: |
| 60 | return |
| 61 | result = await init_async_engine( |
| 62 | self.config.path, self.config.name, self.config.schema_type # type: ignore |
| 63 | ) |
| 64 | self.engine, self.table_model_cls, self.blob_model_cls = result |
| 65 | self.session = async_sessionmaker(self.engine, expire_on_commit=False) |
| 66 | self._initialized = True |
| 67 | self.logger.info(f"SQL storage initialized at {self.config.path}") |
| 68 | |
| 69 | async def write(self, data: List[Experience]) -> None: |
| 70 | await self.prepare() |