|
1 | 1 | import asyncio |
2 | | -from io import TextIOWrapper |
| 2 | +from io import BufferedIOBase |
3 | 3 | import os |
4 | 4 | import time |
5 | 5 | from typing import Any, AsyncGenerator, Dict, Iterable, Optional, TypeVar |
@@ -110,7 +110,7 @@ async def run_migration(dsn: Optional[str] = None) -> str: |
110 | 110 | ) |
111 | 111 |
|
112 | 112 | open_migration_file = open(migration_file) |
113 | | - if isinstance(open_migration_file, TextIOWrapper): |
| 113 | + if isinstance(open_migration_file, BufferedIOBase): |
114 | 114 | with open_migration_file as f: |
115 | 115 | migration_sql = f.read() |
116 | 116 | logging.debug(migration_sql) |
@@ -170,6 +170,7 @@ async def aiter(list: T) -> AsyncGenerator[bytes, None]: |
170 | 170 | line = "\n".join( |
171 | 171 | [item_str.rstrip().replace(r"\n", r"\\n").replace(r"\t", r"\\t")] |
172 | 172 | ).encode("utf-8") |
| 173 | + |
173 | 174 | yield line |
174 | 175 |
|
175 | 176 |
|
@@ -292,7 +293,7 @@ async def load_ndjson( |
292 | 293 | ) -> None: |
293 | 294 | print(f"loading {file} into {table} using {method}") |
294 | 295 | open_file = open(file, "rb") |
295 | | - if isinstance(open_file, TextIOWrapper): |
| 296 | + if isinstance(open_file, BufferedIOBase): |
296 | 297 | with open_file as f: |
297 | 298 | async with DB(dsn) as conn: |
298 | 299 | await load_iterator(f, table, conn, method) |
|
0 commit comments