mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-23 11:37:08 -04:00
Formatting
This commit is contained in:
parent
1f3b24e5b7
commit
35c8932ffb
12 changed files with 151 additions and 363 deletions
12
rip/db.py
12
rip/db.py
|
@ -71,15 +71,11 @@ class Database:
|
|||
|
||||
with sqlite3.connect(self.path) as conn:
|
||||
conditions = " AND ".join(f"{key}=?" for key in items.keys())
|
||||
command = (
|
||||
f"SELECT EXISTS(SELECT 1 FROM {self.name} WHERE {conditions})"
|
||||
)
|
||||
command = f"SELECT EXISTS(SELECT 1 FROM {self.name} WHERE {conditions})"
|
||||
|
||||
logger.debug("Executing %s", command)
|
||||
|
||||
return bool(
|
||||
conn.execute(command, tuple(items.values())).fetchone()[0]
|
||||
)
|
||||
return bool(conn.execute(command, tuple(items.values())).fetchone()[0])
|
||||
|
||||
def __contains__(self, keys: Union[str, dict]) -> bool:
|
||||
"""Check whether a key-value pair exists in the database.
|
||||
|
@ -123,9 +119,7 @@ class Database:
|
|||
|
||||
params = ", ".join(self.structure.keys())
|
||||
question_marks = ", ".join("?" for _ in items)
|
||||
command = (
|
||||
f"INSERT INTO {self.name} ({params}) VALUES ({question_marks})"
|
||||
)
|
||||
command = f"INSERT INTO {self.name} ({params}) VALUES ({question_marks})"
|
||||
|
||||
logger.debug("Executing %s", command)
|
||||
logger.debug("Items to add: %s", items)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue