From cf744eb1f7519ba75f3b85d6abc45e188f2a5f91 Mon Sep 17 00:00:00 2001 From: Mary Koliopoulou Date: Fri, 14 Apr 2017 19:42:23 +0300 Subject: [PATCH] Update db.py --- beets/dbcore/db.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 24ee4a1d7..df42ab05f 100755 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -684,17 +684,17 @@ class Transaction(object): """Execute an SQL statement with substitution values and return the row ID of the last affected row. """ - - cursor = self.db._connection().execute(statement, subvals) - raise AccessFileError("unable to open database file. It might be a permissions problem") - return cursor.lastrowid + try: + cursor = self.db._connection().execute(statement, subvals) + return cursor.lastrowid + except sqlite3.OperationalError as e: + raise AccessFileError("unable to open database file. It might be a permissions problem") def script(self, statements): """Execute a string containing multiple SQL statements.""" self.db._connection().executescript(statements) - class Database(object): """A container for Model objects that wraps an SQLite database as the backend.