Update db.py

This commit is contained in:
Mary Koliopoulou 2017-04-14 19:42:23 +03:00 committed by GitHub
parent cb2f47d8d9
commit cf744eb1f7

View file

@ -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.