How can I setup a Django 1.5.1 app running with Python 3.3 to access a MySQL database? I tried using MySQLdb but apparently it doesn't support Python 3.3.
My next intention was to use Connector/Python, but what am I supposed to put for the "Engine" key of the Databases dictionary of the settings.py file?
If someone could provide detailed steps of how to get Django to work with Connector/Python, that would be great!
MySQLdb is the Python interface to MySQL [supported by django]. Version 1.2.1p2 or later is required for full MySQL support in Django.
At the time of writing, the latest release of MySQLdb (1.2.4) doesn’t support Python 3. In order to use MySQL under Python 3, you’ll have to install an unofficial fork, such as MySQL-for-Python-3.
This port is still in alpha. In particular, it doesn’t support binary data, making it impossible to use django.db.models.BinaryField.
Basically your only options to avoid Alpha quality drivers are:
Don't use python 3.
Don't use MySQL.
Hopefully this makes the choice easier: http://grimoire.ca/mysql/choose-something-else
REF: https://docs.djangoproject.com/en/dev/ref/databases/#python-3
Related
I tried to connect to Sybase database from Django using sqlanydjango, but
I have stuck. One answer saying that
sqlany-django is no longer maintained; it was last updated in May 2016.
What is the other possibility to connect to Sybase database?
OS Ubuntu 18.04
django 2.2.4
Sybase is no longer maintained and it's not supported by Django. I recommend using one of the supported databases:
PostgreSQL
MariaDB
MySQL
Oracle
SQLite
Personally, I would recommend using PostgreSQL - I think it's the most advanced database. If you use it, I would recommend using version 13, since version 14 is still new and I think it's not officially supported by Django yet. It's always a good practice to use the previous major release. Also with Django, I recommend upgrading to the latest major release only about 4 to 6 months after its initial release. So for today, this means using Django 3.2 (latest minor release, currently 3.2.11).
You can use django-environ to define the database you are using in settings.
You could use the freetds module. GitHub repository was active 5 days ago, it aims to provide support for sybase and MSQL Server.
I used it with MSQL
You can download it from there, and installing with the instruction on this link (Sybase python module website)
Then you can test your installation using these steps
You can also try different Django version.
If this doesn't show anything wrong, and Django still won't connect to your DB, you can try to edit Django's source files so the ImproperlyConfigured exception doesn't raise (REALLY REALLY RISKY, DO A BACK UP OF YOUR DB) or migrate your Sybase to a supported database.
You can use pyodbc.
To install this.
Pip install pyodbc
import pyodbc
cnxn = pyodbc.connect(‘DRIVER={Devart ODBC Driver for ASE};Server=myserver;Port=myport;Database=mydatabase;User ID=myuserid;Password=mypassword;String Types=Unicode’)
For reference:-
https://medium.com/#sharma.jayant1992/best-way-to-connect-python-with-sybase-database-76445713efaf
As specified in the tutorial (http://www.jython.org/jythonbook/en/1.0/JythonDjango.html), I am using doj.backends.zxjdbc.postgresql as Django's DB engine. However, when I do
jython manage.py syncdb
I get an ImproperlyConfigured error, stating that doj.backends.zxjdbc.postgresql is not an available backend and that no module named postgresql exists. Strangely, if I enter the Jython shell, I can do
import doj.backends.zxjdbc.postgresql
without any error messages.
Ideas on what is going on here?
Solution: django-jython is out of date. 1.4 is not currently supported, so there is no solution to this issue other than to revert to a supported version of django.
Unfortunately it seems like django-jython is not seeing much/any active development anymore...
However, I have found that development versions available at the Google code repository below do work in Django 1.5 (and I assume they may work with 1.4 too, if you pick the right version):
https://code.google.com/p/django-jython/source/list
In particular, I have found that this dev version works with Django 1.5:
https://code.google.com/p/django-jython/source/detail?r=c4a0dd949a6d86a4baf8d1bed3b1926fa5318e87
I have plans to upgrade my server.My major requirement is python django1.3 and postgres8.4
I am using Django 1.3 and python 2.6.5 currently.Since i want to upgrade the server I want to know whether django 1.3 supports python 2.7.2 ?
I have read the specification that 11.04 comes with python 2.7.1 and 11.10 comes with 2.7.2.
I know that django 1.3 supports 2.4 to 2.7 ? Since i don't want to take any risk on server I want to know whether django 1.3 supports python 2.7.1 or 2.7.2 or both.
Please specify how can i verify i have installed virtual env .I have multiple versions of django and python and they gave the error No module named django.core.management.
Thanks in advance
Django supports all versions of Python 2.7. Since 2.7.1 and 2.7.2 are minor versions of 2.7, Django will work with them.
We are using Django 1.3 and Python 2.7.2 at work for quite some time now, and have not faced any compatibility issues.
If you want to have multiple versions of python to be installed, it is better to use tools like pythonbrew (https://github.com/utahta/pythonbrew).
Regarding the error "No module named django.core.management", you might have installed django with one of your other versions of python. Again, Better to create virtual envs somewhere in your project directories(so they are easy to find), or Even better to use pythonbrew to manage virtual envs.
I want to use multiple databases in my Django project. I currently have Django 1.3 installed and my project uses PostgreSQL.
I want to add an app that uses MongoDB.
As I understand(please correct me if I'm wrong), to support MongoDB, I need Django-nonrel which is a fork that provides support for non-relational databases.
So what do I need to do to get MongoEngine running in my Django project while still keeping support for the Postgre stuff in my project?
Should I just run the setup.py in the Django-nonrel package? Uninstall the official Django 1.3? I'm confused here.
If you're using pip, I think it will do it for you automatically because nonrel marks itself as supplying "django".
You are correct that you will need to uninstall django and install django-nonrel if pip doesn't do that automatically.
As for the apps living on the same project, in your database dictionary you just set one db to use postgres and one to use mongo.
If you have any questions we are here at #django-nonrel on freenode irc.
best thing you can do is installing django non real on virtualenv
http://zcentric.com/2010/09/24/get-django-nonrel-working-with-virtualenv/
this way you can have both working together (don't need to uninstall django first)
Has anyone experience in using Django with the Drizzle database?
The first GA version of Drizzle has just been released and from my understanding it should be be a good match for Django. Being a stripped down version of MySQL it still provides all the needed functionality and hopefully a better performance.
To use the Django MySQL backend, you have to install the MySQLdb driver. When I install MySQLdb on a machine that has Drizzle installed (but not MySQL), I get this error: EnvironmentError: mysql_config not found. I believe this is the step where MySQLdb is looking for compiler options to build the client. We probably need a fork of the Django MySQL backend that uses a Python wrapper around libdrizzle.
MySQLdb is playing just fine with Drizzle. We use it to work with SQLAlchemy.
I can't speak to the issues you encountered, but I also tend to have both MySQL and Drizzle on my machines. Things built ok for me, but I'd be happy to help resolve any issues anyone else is having