有没有人尝试python3+django1.6+mysql connector 1.1.3
展开全部
改掉系统默认的sqlite3数据库,
# Database
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
'ENGINE': 'django.db.backends.mysql',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME':'djangoDB',
'USER':'root',
'PASSWORD':'123456',
'port':'3306',
}
}
然后启动报错,
ImportError: No module named 'MySQLdb'
据说要装MySQL-python
可是MySQL-python一直无法安装成功。
又报错ImportError: No module named 'ConfigParser'
因为python3中叫做configparser,是小写。
好吧,听说不用MySQL-python可以用pymsql代替,然后就赶紧下载pip install pymysql
然后再启动,还是不行啊,还是ImportError: No module named 'MySQLdb'
这里说下MySQL-python吧。
MySQL-python的解释看官方说法
MySQLdb is an interface to the popular MySQL database server for Python. The design goals are:
Compliance with Python database API version 2.0 [PEP-0249]
Thread-safety
Thread-friendliness (threads will not block each other)
MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currently supported. Python-3.0 will be supported in a future release. PyPy is supported.
说白了就是连接mysql的python接口,有了他就可以用python来操作数据库了。类似java的JDBC那一套东西把。
# Database
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
'ENGINE': 'django.db.backends.mysql',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME':'djangoDB',
'USER':'root',
'PASSWORD':'123456',
'port':'3306',
}
}
然后启动报错,
ImportError: No module named 'MySQLdb'
据说要装MySQL-python
可是MySQL-python一直无法安装成功。
又报错ImportError: No module named 'ConfigParser'
因为python3中叫做configparser,是小写。
好吧,听说不用MySQL-python可以用pymsql代替,然后就赶紧下载pip install pymysql
然后再启动,还是不行啊,还是ImportError: No module named 'MySQLdb'
这里说下MySQL-python吧。
MySQL-python的解释看官方说法
MySQLdb is an interface to the popular MySQL database server for Python. The design goals are:
Compliance with Python database API version 2.0 [PEP-0249]
Thread-safety
Thread-friendliness (threads will not block each other)
MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currently supported. Python-3.0 will be supported in a future release. PyPy is supported.
说白了就是连接mysql的python接口,有了他就可以用python来操作数据库了。类似java的JDBC那一套东西把。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询