Python Sqlite3 Operationalerror Disk I/o Error
Contents |
a GitHub account Sign in Create a gist now Instantly share code, notes, and snippets. Star 1 Fork 0 17twenty/fixSQL.py Created
Sqlite3.operationalerror: Disk I/o Error Ipython
Feb 5, 2014 Embed What would you like to do? Embed Embed sqlite disk io error this gist in your website. Embed Share Copy sharable URL for this gist. Share Clone via HTTPS
Sql Error Disk I O Error
Clone with Git or checkout with SVN using the repository's web address. HTTPS Learn more about clone URLs Download ZIP Code Revisions 1 Stars 1 How to fix sqlite3 nfs problems with sqlite3.OperationalError: disk I/O error in Python Raw fixSQL.py """ You'll most likely notice you have a something.db-journal file - that was my first sign! I ended up writing a class to abstract stuff away but the key line is, when creating the table, execute the pragma line: PRAGMA journal_mode = OFF http://www.stevemcarthur.co.uk/blog/post/some-kind-of-disk-io-error-occurred-sqlite/ and for sqlite3.operationalerror: unable to open database file more information see here http://www.sqlite.org/pragma.html I found this was due to weird permissions with the default DELETE option. TRUNCATE works as well as OFF """ class Notes(): def __init__(self): pass def createDatabase(self): """ The goal here is to ensure we have a sane/working default DB """ conn = self.__openAndGetConnection() cur = conn.cursor() # Drop it if it already exists cur.execute('''PRAGMA journal_mode = OFF''') cur.execute("DROP TABLE IF EXISTS notes") # Make a new shiny one cur.execute('''CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, hits INT, title TEXT, author TEXT, note TEXT, creation TIMESTAMP, expiration TIMESTAMP)''') tempStamp = datetime.datetime.now() self.addNote("This is the first note in the database", expiration=tempStamp); # Commit it all conn.commit() self.__close(conn) def addNote(self, note, title="Untitled Masterpiece", expiration=None, author=u"Anonymous"): if not expiration: # Limit to 1 hour expiration = datetime.datetime.now() + (datetime.timedelta(hours=1)) # Make with the unicode note = unicode(note) title = unicode(title) author = unicode(author) # Open it up and slap it in conn = self.__openAndGetConnection() cur = conn.cursor() demoNote = (0, title, author, no
gone offline. I checked the error log, which is filled nonstop with lines like this: 2013-06-24
Sqlite3 Python
17:59:00,764 :Traceback (most recent call last): 2013-06-24 17:59:00,764 :sqlite3.OperationalError: unable to open database file 2013-06-24 17:59:01,813 :Traceback (most recent call last): 2013-06-24 17:59:01,814 :sqlite3.OperationalError: unable to open database file Digging back further in the error log, I found this: OperationalError: disk I/O error 2013-06-24 12:09:15,749 :IOError: write error So, what happened? Did my app suddenly lose write permissions? zauberparacelsus https://gist.github.com/17twenty/8831301 | 12 posts | June 24, 2013, 6:02 p.m. | permalink Do you know the name of your sqlite file? Could you check it still exists and hasn't been deleted. If it's still there, could you check the permissions. Also, could you fire up a python console and try opening the database directly and see if that works. https://www.pythonanywhere.com/forums/topic/723/ Thanks rcs1000 | 292 posts | June 25, 2013, 7:05 a.m. | permalink Good advice from @rcs1000. Will follow up by email, but here is some general advice, in case anyone else has a similar problem: check you haven't maxed out your quota make sure you specify an absolute path to your database -- you can never be sure what the working directory for a web app is. try reloading your web app, as rcs1000 says, try accessing the database from a console -- sqlite3 /path/to/my.db, then .tables or select * from mytable or some insert into commands to check that data is there, and that you can insert new data. try (temporarily?) creating a new database file and switching to that. harry | 1872 posts | PythonAnywhere staff| | June 25, 2013, 10:24 a.m. | permalink Thanks for the reply. The problem was fixed by changing to absolute path, as you suggested. However, I still find this breakage strange because for the past couple of weeks it worked without a problem, and then
here for a quick overview of the site Help Center Detailed answers to any http://stackoverflow.com/questions/21352285/ipython-operationalerror-disk-i-o-error questions you might have Meta Discuss the workings and policies of http://dba.stackexchange.com/questions/44156/disk-i-o-error-in-sqlite this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow disk i is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ipython: OperationalError: disk I/O error up vote 0 down vote favorite I was running ipython successfully on fedora 18 until now: I'm getting the following exception when trying to launch it: disk i/o error Traceback (most recent call last): File "/usr/bin/ipython", line 9, in
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top disk I/O error in SQLite up vote 2 down vote favorite 1 What are the possible things that would trigger the "disk I/O error"? I've been having this problem and I couldn't find a solution. I have a SQLite3 database, and I'm trying to insert data from a file that contains SQL inserts. Sample data in the file: insert into files (filesize, filedate, md5, fullpath, origin) values (5795096,1370159412, "e846355215bbb9bf5f30102a49304ef1", "SDs/16G-1/DSC00144.JPG", "SDs"); insert into files (filesize, filedate, md5, fullpath, origin) values (5435597,1370159422, "1a7bcf3a4aaee3e8fdb304ab995ff80f", "SDs/16G-1/DSC00145.JPG", "SDs"); insert into files (filesize, filedate, md5, fullpath, origin) values (5121224,1370159432, "16d28e83599c731657a6cd7ff97a4903", "SDs/16G-1/DSC00146.JPG", "SDs"); I tried inserting that in the db file with the following command: $ sqlite3 allfiles.db < insert.sql See below the error that I get: Error: near line 27: disk I/O error Error: near line 28: disk I/O error Error: near line 34: disk I/O error Error: near line 39: disk I/O error Error: near line 47: disk I/O error Error: near line 129: disk I/O error The input lines that don't generate error are successfully included, but I don't understand why some lines ha