I am using MySql db.i made following changes but now i am getting following error
DATABASES = {
'default': {
'NAME': 'test',
'ENGINE': 'sqlserver_ado',
'HOST':'127.0.0.1',
'USER': 'mssql',
'PASSWORD': 'mssql',
'PORT': '1434'
}
}
"ImportError: No module named 'django.db.backends.util' "
You've probably installed django-mssql version 1.7 which supports <= Django 1.8.
You can try django-mssql-1.8b2:
pip install django-mssql==1.8b2
Beware that this is probably a beta version, so it might not be suitable for you.
The error means that you don't have suitable db backends for mssql. You can install https://github.com/lionheart/django-pyodbc as db backend.
Related
I want to set the mysql database using mysql-connector-python for setting up a web site made with Django using a database backend but I get this error:
django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
My credentials (name, user, password, host, port) works fine, so the problem isn't here.
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'library',
'USER': 'username',
'PASSWORD': 'password',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {
'autocommit': True,
'use_pure': True,
},
}
}
I'm using python 3.8.5 and mysql-connector-python 8.0.21 and I understand that mysql-connector-python, starting from version 8.0.13, has a bug, which makes it impossible to use with Django and to avoid the bug I added ‘use_pure’: True in database options. But it doesn't work.
I found this question but it doesn't say anything about using ‘use_pure’: True.
If the mysql-connector-python isn't compatible with python 3, what can I use instead? (I can't wait for the support release).
you do not have the option to use mysql connector, you have to install mysql-client from https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient and try installing all the wheels incase you get errors, while installing using pip install
When I try to connect my app to postgresql db I always get this same error:
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'sqlite3'
Here is my code in settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mydb',
'USER': 'postgres',
'PASSWORD': 'pass123',
'HOST': 'localhost',
'PORT': '5432'
}
}
I am using django version 3.0.2 and my psycopg2 version 2.8.5 . I did downgrade to earlier version of django and still the problem persists. Also my python version is 3.8.
I tried doing this too
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USER': 'postgres',
'PASSWORD': 'pass123',
'HOST': 'localhost',
'PORT': '5432'
}
}
I thought it was the issue with the virtual env so I decided to perform on other projects too but still does not work. Can anyone please help me.
I fixed it by uninstalling the psycopg2. I installed psycopg2-binary.
pip install psycopg2-binary
My question is similar to the one at error connecting mysql to django which has gone unanswered.
I am using python 3.6.5, mysql server-5.7.29 and Ubuntu 18.04 LTS. I am trying to setup mysql for my django application but I am receiving Segmentation fault.
(env) monu#monu:~/Desktop/ShubhamProject/ShubhamProject$ python manage.py runserver
Segmentation fault (core dumped)
If I use the default sqlite3 database, server comes up.
Database section in settings.py looks like
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sports_website',
'USER': 'nonroot',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3306',
}
}
Using the following packages
asgiref==3.2.3
Django==3.0.3
django-crispy-forms==1.8.1
mysqlclient==1.4.6
pytz==2019.3
sqlparse==0.3.0
install pymysql and add below in settings.py on top.
import pymysql
pymysql.version_info = (1, 4, 6, 'final', 0)
pymysql.install_as_MySQLdb()
this is because django use MySQLdb drive,but MYSQLdb not support python3, so set the drive is pymysql in settings.py:
first :pip install pymysql
and add: import pymysql
pymysql.install_as_MySQLdb()
am new to python and django
I am trying to build a small python django application on my local windows laptop.
i am not able to underlying tables required for my Django project as when i run "python manage.py syncdb" i get the below error
` Error :django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python? '
And when i try running "pip install mysqlclient" i get the below error
'error: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279'
I am stuck in this step and not able to find any leads. can someone suggest any workaround
By default Django is configured to use Sqlite database. See settings.py file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
You have it configured to use MySQL database:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DATABASE_NAME',
'USER': 'DB_USERNAME',
'PASSWORD': 'DB_PASSWORD',
'HOST': '127.0.0.1',
'PORT': '3306'
}
}
If it's a small test project, I would recommend you to switch back to Sqlite, but if you intend to run your project later in production using MySQL, then better use MySQL in development process.
Install:
MySQL or MariaDB locally on your computer
Windows SDK from www.microsoft.com/download/details.aspx?id=8279
run pip install mysqlclient - now it should succeed
I have installed django-sqlserver (0.5) with pip. In the docs says that engine must be sqlserver_ado but it does not work, this is the output Error was: No module named sqlserver_ado
This is my settings file:
options = {'use_mars': True,
'allow_nulls_in_unique_constraints': False, # sqlserver doesn't fully support multiple nulls in unique constraint
'extra_params': 'DataTypeCompatibility=80;MARS Connection=True;',
'use_legacy_date_fields': False,
}
DATABASES = {
'default': {
'ENGINE': 'sqlserver_ado',
'HOST': 'ip',
'NAME': 'db',
'USER': 'user',
'PASSWORD': 'password',
'OPTIONS': options,
}
}
You need django-mssql which is imported using import sqlserver_ado
The relevant info from the django-mssql docs:
Although the project is named django-mssql the python module is named sqlserver_ado
Python
This backend requires Python 2.6 or newer. Python 3.x support will be investigated when Django supports it.
The django packages page shows no support for python 3