#
#settings.py 里配置:
#
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'dbname', # Or path to database file if using sqlite3.
'USER': 'uname', # Not used with sqlite3.
'PASSWORD': 'pwd', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
}
}
#
#用MySQLdb
#
conn=MySQLdb.connect(user='uname', db='dbname', passwd='pwd', host='127.0.0.1', use_unicode=True, charset='utf8')