add log to audiobooks edit database
This commit is contained in:
1 parent
3d585d14e0
commit
80ad918686
1 file changed
+9
-2
Regular → Executable
+9
-2
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import re
|
||||
import sqlite3
|
||||
@@ -33,6 +34,11 @@ def load_genre(conn, unique=False):
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-p", "--print-only",
|
||||
action="store_true",
|
||||
help="Print data only",
|
||||
)
|
||||
parser.add_argument(
|
||||
"database",
|
||||
type=Path,
|
||||
@@ -53,7 +59,6 @@ def main():
|
||||
|
||||
for genre in list_genres:
|
||||
print(genre)
|
||||
|
||||
for book_id, genres_json in cur.execute("SELECT id, genres FROM books"):
|
||||
if not genres_json:
|
||||
continue
|
||||
@@ -78,6 +83,8 @@ def main():
|
||||
new_genres.append(genre)
|
||||
|
||||
new_genres = sorted(set(new_genres))
|
||||
|
||||
print("Write to Database")
|
||||
|
||||
cur.execute(
|
||||
"UPDATE books SET genres=? WHERE id=?",
|
||||
@@ -87,4 +94,4 @@ def main():
|
||||
db.commit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
Reference in new issue
Block a user