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.