SQLITE Database path

This is the place for queries that don't fit in any of the other categories.

SQLITE Database path

Postby linuxdesire » Tue Dec 03, 2013 4:44 pm

I am following a tutorial from Python Central. But I am not able to open my sqlite database. I am thinking it is because I do not understand how to input the correct path. I am using Python 3.3.3, Here is what the tutorial shows.

Code: Select all
import sqlite3
db = sqlite3.connect(' :memory:')
db = sqlite3.connect(' :data/my.db')

In the data/my.db, I input links/StudentData.db. Where links is my folder on my desktop and of course StudentData is my database.

I get this error:
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
db = sqlite3.connect('links/StudentData.db')
sqlite3.OperationalError: unable to open database file

I am using Windows 7.
Posts: 13
Joined: Fri Nov 15, 2013 6:45 pm

Re: SQLITE Database path

Postby ochichinyezaboombwa » Wed Dec 04, 2013 4:42 am

Read the Python Central's page one more time, this time carefully. There is no
Code: Select all
' :data/my.db'
there: this is an invalid path in any (I think) operating system. You cannot write "approximately something like, you know, what's required...." -- the code must be literal and 100% correct.
Posts: 203
Joined: Tue Jun 04, 2013 7:53 pm

Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 5 guests