summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2024-07-03 11:30:50 +0200
committercos <cos>2024-07-03 16:06:15 +0200
commitb4d369f44e02f2c87d4270e5adbe65b9c97cb6df (patch)
tree1fb01316b7878f08c7d69f465db9082bb5b29473
parentf11398a042a7de218a53d2aa567299515edf9f60 (diff)
downloadAntennaPodDbFixer-b4d369f44e02f2c87d4270e5adbe65b9c97cb6df.zip
Move query() to other functions
-rwxr-xr-xAntennaPodDbFixer.py34
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"]