question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create_db and getDB do not accept `pathlib Paths`

See original GitHub issue

Describe the bug The operations in the title do not support a Path argument for the DB. Usage requires converting to string

How to reproduce

from pathlib import Path
from pysondb import db

BASE_DIR = Path(__file__).absolute().parent
AUDIT_PATH = BASE_DIR / "audit/"
AUDIT_DB = AUDIT_PATH / "audit_db.json"

def setup_audit_db() -> None:
    """setup_audit_db
    Establishes the audit directory and database if
    does not exist"""
    print(f"Establishing audit database {AUDIT_DB}")
    os.makedirs(AUDIT_PATH, exist_ok=True)
    db.create_db(AUDIT_DB)

Expected behavior Expected that string or Path would work in the noted operations

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
FrankC01commented, Oct 13, 2021

Look forward to the change.

2reactions
Adwaith-Rajeshcommented, Oct 13, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

pathlib — Object-oriented filesystem paths — Python 3.11.1 ...
Pure paths¶. Pure path objects provide path-handling operations which don't actually access a filesystem. There are three ways to access these classes, which...
Read more >
python Path from pathlib module doesn't add path separator
Path cannot assume how the result will be used further, so it constructs the path object from the input data as is.
Read more >
accept pathlib paths wherever a path/file is expected #11033
i'd like pd.read_table(some_path / 'filename.tsv') to work without going through str()
Read more >
Python 3's pathlib Module: Taming the File System
Unfortunately, pathlib does not explicitly support safe moving of files. To avoid possibly overwriting the destination path, the simplest is to test whether ......
Read more >
Python Path – How to Use the Pathlib Module with Examples
To understand how you can construct a basic path using Pathlib, ... In this case, PurePath() doesn't allow us to know the drive's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found