0

I'm newbie to Python. I want to import sqlite3 in my script. Everything works correctly until I move my script to another subfolder.

This is my script:

#!/usr/bin/python

import sqlite3

conn = sqlite3.connect('test.db')

If I create this script in C://Python34 it's ok. But if I move it to C://Python34/test it fails to import sqlite3.

Traceback (most recent call last):
  File "C:\Python34\test\sqlite3.py", line 3, in <module>
    import sqlite3
  File "C:\Python34\test\sqlite3.py", line 5, in <module>
    conn = sqlite3.connect('test.db')
AttributeError: 'module' object has no attribute 'connect'

So, how to import sqlite lib properly to make it work in any subdir?

idjaw
  • 25,487
  • 7
  • 64
  • 83
mr.boris
  • 3,667
  • 8
  • 37
  • 70

0 Answers0