Get a resolved path for a SQLite database file (or memory URI)
(
db_path: StrOrPath, use_cache_dir: bool, use_temp: bool, use_memory: bool = False
)
| 462 | |
| 463 | |
| 464 | def _get_sqlite_cache_path( |
| 465 | db_path: StrOrPath, use_cache_dir: bool, use_temp: bool, use_memory: bool = False |
| 466 | ) -> StrOrPath: |
| 467 | """Get a resolved path for a SQLite database file (or memory URI)""" |
| 468 | # Use an in-memory database, if specified |
| 469 | db_path = str(db_path) |
| 470 | if use_memory: |
| 471 | return MEMORY_URI |
| 472 | elif ':memory:' in db_path or 'mode=memory' in db_path: |
| 473 | return db_path |
| 474 | |
| 475 | # Add file extension if not specified |
| 476 | if not Path(db_path).suffix: |
| 477 | db_path += '.sqlite' |
| 478 | return get_cache_path(db_path, use_cache_dir, use_temp) |
| 479 | |
| 480 | |
| 481 | def get_cache_path(db_path: StrOrPath, use_cache_dir: bool = False, use_temp: bool = False) -> Path: |
no test coverage detected
searching dependent graphs…