diff options
author | cos <cos> | 2024-07-03 11:30:50 +0200 |
---|---|---|
committer | cos <cos> | 2024-07-03 16:06:15 +0200 |
commit | b4d369f44e02f2c87d4270e5adbe65b9c97cb6df (patch) | |
tree | 1fb01316b7878f08c7d69f465db9082bb5b29473 | |
parent | f11398a042a7de218a53d2aa567299515edf9f60 (diff) | |
download | AntennaPodDbFixer-b4d369f44e02f2c87d4270e5adbe65b9c97cb6df.zip |
Move query() to other functions
-rwxr-xr-x | AntennaPodDbFixer.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/AntennaPodDbFixer.py b/AntennaPodDbFixer.py index 5e78924..85d0e12 100755 --- a/AntennaPodDbFixer.py +++ b/AntennaPodDbFixer.py @@ -34,6 +34,23 @@ def integrity_is_ok(fileName): print(integrityCheck) return is_ok +# Insert relevant columns into a new database +def query(db, query): + result = "" + try: + result = subprocess.run( + ["sqlite3", "-init", "/tmp/conf", "-json", db, query], + capture_output=True, + check=True, + text=True + ).stdout + return json.loads(result) + except subprocess.CalledProcessError as err: + print(err.stderr, file=sys.stderr) + exit(1) + except json.decoder.JSONDecodeError as err: + return result + try: opts, args = getopt.gnu_getopt(sys.argv, "hv", ["help", "verbose"]) except getopt.GetoptError as err: @@ -127,23 +144,6 @@ subprocess.run(["sqlite3", workingcopyFilePath], stdin=open(sqlFilePath, 'r')) print() -# Insert relevant columns into a new database -def query(db, query): - result = "" - try: - result = subprocess.run( - ["sqlite3", "-init", "/tmp/conf", "-json", db, query], - capture_output=True, - check=True, - text=True - ).stdout - return json.loads(result) - except subprocess.CalledProcessError as err: - print(err.stderr, file=sys.stderr) - exit(1) - except json.decoder.JSONDecodeError as err: - return result - tables = query(emptyFilePath, "SELECT name FROM sqlite_schema WHERE type='table';") for table in tables: table = table["name"] |