Python Sqlite3 Database Error
Question: I am trying to run a program to put prices into the database but when I try to
write to the database I get an error. I'm using Python3.4 and I have sqlite
version 3.7.14.1

    
    
    import sqlite3
    con = sqlite3.connect('/../../stocks.db')
    cur = con.cursor()
    cur.execute("insert into apple values (?,?)",(price,time))
    con.commit()
    
    #error
    cur.execute("insert into apple values (?,?)",(price,time))
    sqlite3.DatabaseError: file is encrypted or is not a database
    


Answer: Try replacing `con = sqlite3.connect('/../../stocks.db')`

with

    
    
    con = sqlite3.connect('../../stocks.db')
    

or with the correct path to stocks.db

In `con = sqlite3.connect('/../../stocks.db')`, `/` as the first character of
a path means the root directory, and from `/` the parent `..` is also the root
directory `/`

So `/../../stocks.db` is `/stocks.db` which is probably not where the
stocks.db actually is, if you meant a relative path.

When a db file does not exist, sqlite3 will still try to open it as a new
database _if file permissions permit_. However, in this case the user probably
doesn't have permission to write to the root directory at `/stocks.db`

