[Tutor] SQLite database creation bafflement
Che M
pine508 at hotmail.com
Mon Aug 20 09:17:08 CEST 2007
Hi, I am trying to simply create an SQLite database with Python. I find
that when I try to create a new database file, *sometimes* it lets me do it,
and sometimes it doesn't, and the only thing I am changing is the name of
the database. I am baffled as to why some names appear to work and some
don't. For example, this will create a brand new database on the desktop:
import sqlite3
conn = sqlite3.connect('C:\Documents and
Settings\user\Desktop\mydatabase.db')
But running *this*--only thing different is the database's name--gives the
error, as shown:
import sqlite3
conn = sqlite3.connect('C:\Documents and
Settings\user\Desktop\adatabase.db')
Traceback (most recent call last):
File "C:/Documents and Settings/user/Desktop/sqlitetester", line 5, in
<module>
conn = sqlite3.connect('C:\Documents and
Settings\user\Desktop\adatabase.db')
OperationalError: unable to open database file
The only thing that is different is one is called "mydatabase.db" (works)
and the other is called "adatabase.db" (doesn't work).
I've tested lots of different names, and it seems random to me what will
work and what won't. E.g., "banana.db" and "apple.db" don't work, but
"peach.db" and "pear.db" do It is also consistent with each name (that is,
if I am successful and then remove the .db file from the desktop, that name
will always work again to create a new .db file).
None of this makes any sense: it should be able to use anything, shouldn't
it? I assume I am missing something obvious. Any help would help restore
sanity to acceptable levels. Thanks.
_________________________________________________________________
Booking a flight? Know when to buy with airfare predictions on MSN Travel.
http://travel.msn.com/Articles/aboutfarecast.aspx&ocid=T001MSN25A07001
More information about the Tutor
mailing list