In PHP, To refer to a higher directory I would use '../../test'; How would I do it in Python?
In this case, I'm using SQLite to create a database file.
import sqlite3
conn = sqlite3.connect('../data/test.db')
However; it says 'unable to open database file' which I'm considering as a directory access error. How do I refer to higher directory in Python?
You might try this:
conn = sqlite3.connect(os.path.realpath('../data/test.db'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With