Skip to content
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

provide information how to handle "sqlite3.OperationalError: attempt to write a readonly database" in exception message #4753

Closed
ghost opened this issue Jan 1, 2014 · 6 comments
Milestone

Comments

@ghost
Copy link

ghost commented Jan 1, 2014

I'm experiencing an sqlite3.OperationalError: attempt to write a readonly database
(stack trace attached). As this seems to be an error related to a database connection, the error message could be more precise (which is my enhancement request), specifying the failed connection parameters (at least host and port). It is not clear what the program expects thought it could be.

stacktrace

Error in sys.excepthook:
Traceback (most recent call last):
File "/mnt/DATA/sources/ipython/IPython/core/application.py", line 175, in excepthook
return self.crash_handler(etype, evalue, tb)
File "/mnt/DATA/sources/ipython/IPython/core/crashhandler.py", line 158, in call
traceback = TBhandler.text(etype,evalue,etb,context=31)
File "/mnt/DATA/sources/ipython/IPython/core/ultratb.py", line 412, in text
tb_offset, context)
File "/mnt/DATA/sources/ipython/IPython/core/ultratb.py", line 963, in structured_traceback
ipinst = ipapi.get()
File "/mnt/DATA/sources/ipython/IPython/core/ipapi.py", line 28, in get
return InteractiveShell.instance()
File "/mnt/DATA/sources/ipython/IPython/config/configurable.py", line 318, in instance
inst = cls(_args, *_kwargs)
File "/mnt/DATA/sources/ipython/IPython/core/interactiveshell.py", line 436, in init
self.init_history()
File "/mnt/DATA/sources/ipython/IPython/core/interactiveshell.py", line 1489, in init_history
self.history_manager = HistoryManager(shell=self, config=self.config)
File "/mnt/DATA/sources/ipython/IPython/core/history.py", line 409, in init
self.new_session()
File "", line 2, in new_session
File "/mnt/DATA/sources/ipython/IPython/core/history.py", line 60, in needs_sqlite
return f(a,*kw)
File "/mnt/DATA/sources/ipython/IPython/core/history.py", line 427, in new_session
NULL, "") """, (datetime.datetime.now(),))
sqlite3.OperationalError: attempt to write a readonly database

Original exception was:
Traceback (most recent call last):
File "/usr/bin/ipython", line 7, in
launch_new_instance()
File "/mnt/DATA/sources/ipython/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "", line 2, in initialize
File "/mnt/DATA/sources/ipython/IPython/config/application.py", line 84, in catch_config_error
return method(app, _args, *_kwargs)
File "/mnt/DATA/sources/ipython/IPython/frontend/terminal/ipapp.py", line 324, in initialize
self.init_shell()
File "/mnt/DATA/sources/ipython/IPython/frontend/terminal/ipapp.py", line 340, in init_shell
ipython_dir=self.ipython_dir)
File "/mnt/DATA/sources/ipython/IPython/config/configurable.py", line 318, in instance
inst = cls(_args, *_kwargs)
File "/mnt/DATA/sources/ipython/IPython/frontend/terminal/interactiveshell.py", line 360, in init
user_module=user_module, custom_exceptions=custom_exceptions
File "/mnt/DATA/sources/ipython/IPython/core/interactiveshell.py", line 436, in init
self.init_history()
File "/mnt/DATA/sources/ipython/IPython/core/interactiveshell.py", line 1489, in init_history
self.history_manager = HistoryManager(shell=self, config=self.config)
File "/mnt/DATA/sources/ipython/IPython/core/history.py", line 409, in init
self.new_session()
File "", line 2, in new_session
File "/mnt/DATA/sources/ipython/IPython/core/history.py", line 60, in needs_sqlite
return f(a,*kw)
File "/mnt/DATA/sources/ipython/IPython/core/history.py", line 427, in new_session
NULL, "") """, (datetime.datetime.now(),))
sqlite3.OperationalError: attempt to write a readonly database

output of python -c "import IPython; print(IPython.sys_info())":

{'commit_hash': '858d539',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/usr/local/lib/python2.7/dist-packages/IPython',
'ipython_version': '0.13.2',
'os_name': 'posix',
'platform': 'Linux-3.11.0-14-generic-x86_64-with-Ubuntu-13.10-saucy',
'sys_executable': '/usr/bin/python',
'sys_platform': 'linux2',
'sys_version': '2.7.5+ (default, Sep 19 2013, 13:48:49) \n[GCC 4.8.1]'}

It would be nice to have a possibility to attach files to the issue report and to be able to search the already committed issues (!!).

@takluyver
Copy link
Member

sqlite uses a file, not a database server. By default, it will be saving in ~/.ipython/profile_default/history.sqlite. Does that file exist, and is it writable?

@ghost
Copy link
Author

ghost commented Jan 1, 2014

Thanks for the hint! The file had the wrong permissions (not writable). I suggest to improve error message/output.

@minrk
Copy link
Member

minrk commented Jan 2, 2014

It would be nice to have a possibility to attach files to the issue report

It is common to use gists.

and to be able to search the already committed issues (!!).

The search field is located at the top of the page.

@CleverProgrammer
Copy link

I tried this and it worked. Thank you @takluyver, @richtekp.

~/.ipython/profile_default/history.sqlite
/Users/ChessTastic/.ipython/profile_default/history.sqlite.
➜  profile_default  sudo chmod a+w history.sqlite
Password:

@SagarDollin
Copy link

I cant find the ~/.ipython/profile_default/history.sqlite (im using ubuntu 20.04) ? Could you help me locate it?

@MrMino
Copy link
Member

MrMino commented Mar 27, 2022

You can find the history file by typing %config HistoryManager.hist_file. This will give you a path to the history file:

In [1]: %config HistoryManager.hist_file                                  
Out[1]: PosixPath('/home/mrmino/.ipython/profile_default/history.sqlite') 

This file has to be accessible for the history feature of IPython to work properly. You can use the following snippet to check whether it is:

import os                           
p = %config HistoryManager.hist_file
os.access(p, os.W_OK | os.R_OK)     

If it's not, use your operating system facilities to make it so (e.g. chown / chmod on Linux).

@MrMino MrMino closed this as completed Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants