-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OperationalError from SQlite that indicates a permissions problem. #2508
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
11e3a5a
OperationalError from SQlite that indicates a permissions problem on …
Mary011196 3fd04ad
adding AccessFileError as new class error excpetion
Mary011196 bccfcb6
handlinig AccessFileError in main
Mary011196 cb2f47d
Update db.py
Mary011196 cf744eb
Update db.py
Mary011196 f7a5844
Change the error name to DBAccessError
Mary011196 0492741
Error check with if statemetnt
Mary011196 e756f98
Correcting the mistakes that Travis CI showed me
Mary011196 621427f
Reformat a docstring
sampsyo 19e0958
Re-raise other errors
sampsyo 906bd97
Hint about database access errors
sampsyo 7eaaa99
Changelog entry for #2508
sampsyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handler already catches errors when we open the database. The bug report on this thread arises after the database is already opened, when it is accessed. So I think the new exception handling bit will need to go in the main function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
I add this in main but it gives me the message from the first
UserError
excpetion that raised before.Is there a way to do it like
db_query.InvalidQueryError
in order to check themutate
function in db.py?Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, cool! Looks like you're almost there. There are actually two ways to go with this:
UserError
and let the top-level (main
) exception handling print the message.main
, just catch theOperationalError
directly and print the error message there. (But don't raise a newUserError
.)It's actually a difficult call to say what's better, but I like your idea of raising a new, specialized exception in
mutate
. In fact, maybe we can invent a new error exception class, sort of likeInvalidQueryError
, for filesystem access problems like this one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
I' ve tried both ways but i have the same problem. In the first way i just add in mutate
raise UserError("unable to open database file. It might be a permissions problem")
and in the second way i wrote inmain
this:I wrote also a new error exception class
In order to work with this way i have to raise an
AccessFileError
in mutate and catch it in themain
?Thank you very much!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i fixed it and i tried it with all ways. But it works when i deny the write permission in my database file and the traceback that gives me is
attempt to write a readonly database
. Is this right??Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly!
It's somewhat hard to know exactly what causes specific kinds of errors in the SQLite library, which hides the precise details of what went wrong. But if you see that error when setting the database file to have permissions that prevent writing by your user, that does sound like something we should handle—perhaps in addition to the existing "unable to open database file" error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But when it gives me the "unable to open datapase file" error it prints the message of UserError that raise the _open_library. Maybe the way i change my settings is wrong?
Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm… can you try pushing your updated code so it appears here in the PR? Then I can take a look at how it's actually working.