I installed jython, django on my windows system. I successfully created a project mysite. Now after updating s开发者_开发问答ettings in settings.py. i ran 'manage.py' and got the error- Import error - "no module named mysqldb". now, i downloaded mysqldb (which is for python, but i thought it will work for jython also) and i tried to install it. but now i am getting the following error- import error - "no module named '_winreg'".
what does it mean? how to get around this problem? i am a completely new bee to jython and django, please help.
MySQLdb is the CPython MySQL library, so it won't work with Jython.
You'll want to use zxJDBC to connect to MySQL from Jython: http://jython.org/Project/userguide.html#database-connectivity-in-jython
You'll need to add the MySQL jdbc jar to your classpath
You'll need to install django-jython
in order to get Django working on Jython. Note that it will use zxJDBC
and not MySQLdb.
You can also use PyMySQL (https://github.com/PyMySQL/PyMySQL - pure Python MySQL client). For me it works better than JDBC based driver, which seems to have problems with timezones.
In order to use PyMySQL instead of MySQLdb with standard MySQL DB-backend in my Django project I've added the following code to manage.py file.
import pymysql
pymysql.install_as_MySQLdb()
精彩评论