Make sqlite open errors clearer #1

Merged
dave merged 2 commits from dpedu/db-debug into master 2022-12-24 14:41:45 -08:00
2 changed files with 9 additions and 5 deletions
Showing only changes of commit e5158cfdc7 - Show all commits

View File

@ -10,7 +10,7 @@ from collections import Iterable
from pysonic.scanner import PysonicFilesystemScanner
logging = logging.getLogger("database")
logger = logging.getLogger("database")
LETTER_GROUPS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
@ -63,7 +63,8 @@ class PysonicDatabase(object):
self.scanner = PysonicFilesystemScanner(self)
def open(self):
logging.debug("opening database: %s", self.path)
with open(self.path, "rb"): # sqlite doesn't give very descriptive permission errors, but this does
pass
self.db = sqlite3.connect(self.path, **self.sqlite_opts)
self.db.row_factory = dict_factory
@ -159,14 +160,14 @@ class PysonicDatabase(object):
# Initialize DB
if len(c.fetchall()) == 0:
logging.warning("Initializing database")
logger.warning("Initializing database")
for query in queries:
c.execute(query)
c.execute("COMMIT")
else:
# Migrate if old db exists
# c.execute("""UPDATE meta SET value=? WHERE key="db_version";""", (str(version), ))
# logging.warning("db schema is version {}".format(version))
# logger.warning("db schema is version {}".format(version))
pass
def get_artist_info(self, item_id):

View File

@ -1,5 +1,8 @@
#!/bin/bash
chown -R app:app /db/
set -x
chmod 755 /db/.
chown -R app:app /db
exec sudo --preserve-env -Hu app pysonicd $@