add test on whether paths are indeed unique
This commit is contained in:
parent
0b8c041ee5
commit
65cd55ec0a
1 changed files with 9 additions and 0 deletions
|
|
@ -15,6 +15,14 @@ def has_valid_times(result: pd.DataFrame) -> bool:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def are_keys_unique(db: Path, table: str, col: str) -> bool:
|
||||||
|
conn = sqlite3.connect(db)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute(f"SELECT COUNT( DISTINCT CAST(path AS nvarchar(4000))), COUNT({col}) FROM {table};")
|
||||||
|
results = c.fetchall()[0]
|
||||||
|
conn.close()
|
||||||
|
return bool(results[0] == results[1])
|
||||||
|
|
||||||
|
|
||||||
def check_db_integrity(path: Path) -> None:
|
def check_db_integrity(path: Path) -> None:
|
||||||
db = get_db_file(path)
|
db = get_db_file(path)
|
||||||
|
|
@ -27,6 +35,7 @@ def check_db_integrity(path: Path) -> None:
|
||||||
raise ValueError(f"Result with id {result[id]} has wrong time signatures.")
|
raise ValueError(f"Result with id {result[id]} has wrong time signatures.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def full_integrity_check(path: Path) -> None:
|
def full_integrity_check(path: Path) -> None:
|
||||||
check_db_integrity(path)
|
check_db_integrity(path)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue