- changed milestone to 1.0
- changed component to engine
- changed title to look into upgrading exception formatting to better separate wrapped exception from statement
- marked as enhancement
look into upgrading exception formatting to better separate wrapped exception from statement
Issue #3172
resolved
In a special case (described below) when trying to update a sqlite3 database file located in a directory I have no write permissions to, I obtain quite a misleading error message:
unable to open database file "insert into ......."
I.e. it looks like Sqlalchemy thinks the SQL is in fact a path to the database.
How to replicate
(tested on Linux OS)
Manually (i.e. not using a Python code) create a sqlite3 database, e.g. /home/you/data/test.db with some table in it:
CREATE TABLE cache (key text primary key, value text);
Remove your write permissions from the data directory (i.e. not the file itself!).
Run the following code:
from sqlalchemy import create_engine
en = create_engine('sqlite:////home/you/data/test.db')
en.execute("INSERT INTO cache (key, value) VALUES ('foo', 'bar')")
Comments (3)
-
repo owner -
repo owner possible patch:
diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index a82bae3..e4d6c0a 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -244,7 +244,8 @@ class StatementError(SQLAlchemyError): "(%s)" % det for det in self.detail ] + [ SQLAlchemyError.__str__(self), - repr(self.statement), repr(params_repr) + "(original statement:", repr(self.statement), + repr(params_repr), ")" ]) def __unicode__(self):
-
repo owner - changed status to resolved
- Exception messages have been spiffed up a bit. The SQL statement
and parameters are not displayed if None, reducing confusion for
error messages that weren't related to a statement. The full
module and classname for the DBAPI-level exception is displayed,
making it clear that this is a wrapped DBAPI exception. The
statement and parameters themselves are bounded within a bracketed
sections to better isolate them from the error message and from
each other.
fixes
#3172
→ <<cset 6f40eb37cbdc>>
- Log in to comment