import sqlite3

willgun willgun at live.cn
Thu Jun 4 02:14:18 EDT 2009


Andrew McNamara 写道:
> 
> On 04/06/2009, at 3:15 PM, willgun wrote:
>>
>> When i run the following in IDLE:
>> IDLE 2.6.1
>>>>> import sqlite3
>>>>> con =sqlite3.connect (r'g:\db1')
>>>>>
>> everything goes well,but when i save these to a .py file and run it:
>>
>>>>>
>> Traceback (most recent call last):
>>  File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 2, in <module>
>>    import sqlite3
>>  File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in <module>
>>    con=sqlite3.connect(r'g:\db1')
>> AttributeError: 'module' object has no attribute 'connect'
>>
>> Anyone can tell me why?
> 
> What did you call the .py file? sqlite3.py? If so, you've just imported 
> your own module again. 8-)
> 
> After the import, try "print sqlite3.__file__", which will tell you 
> where the module came from.
Thank you all the same.
I'm a student from China.It's painful for us to read python 
documentation entirely due to poor english.So I often make these mistakes.



More information about the Python-list mailing list