2011-10-06 17 views

回答

5

您正在尋找這樣的:

21 try: 
22  try: 
23   from pysqlite2 import dbapi2 as Database 
24  except ImportError, e1: 
25   from sqlite3 import dbapi2 as Database 
26 except ImportError, exc: 
27  from django.core.exceptions import ImproperlyConfigured 
28  raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc) 

它首先嚐試導入PySqlite,外部模塊。如果失敗了,它會嘗試導入Python 2.5+中包含的sqlite3模塊。如果既不安裝Python 2.5+也不安裝外部模塊,則失敗。它不包含它自己的副本。

+0

啊,太棒了!完善 – drozzy

4

SQLite是Python標準庫的一部分,所以它總是提供給Django的。

3

我認爲SQLite標準配置了Python 2.5+,因此它不需要與Django捆綁在一起。