I’m trying to follow the example the python manual gives for interfacing with SQLite. This first line of code seems to not be working correctly:
import sqlite3
So trying to import python’s sqlite3 module is trying to import python’s datetime from the calling scripts directory instead of wherever it lives, as seen from the traceback below. I cant figure out why. What am I missing?
Traceback (most recent call last):
File "sqlite_test.py", line 3, in <module>
import sqlite3
File "/usr/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/lib/python2.7/sqlite3/dbapi2.py", line 24, in <module>
import datetime
File "/home/brian/dev/py/datetime.py", line 3, in <module>
now = datetime.now()
AttributeError: 'module' object has no attribute 'now'
Just rename
/home/brian/dev/py/datetime.pymodule to something other thandatetime.py, cause it has the same name with the datetime builtin module.Please avoid naming your modules with the same name as standard-library or built-in module names.