Can i use sqlserver in django 1.6 and python3 - python

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

Related

Django error when using mysql-connector-python

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

Creating SuperUser on a custom database (not default)

I am currently working on a multi-tenant django application. Since the requirement of multi-tenancy, for starters, I have created a second database. However, I am unable to create a SuperUser in the newly created database.
I did try the answer listed Django fails to create superuser in other db than 'default'
However, no luck.
Getting the following output on compile:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly co
nfigured. Please supply the ENGINE value. Check settings documentation for more
details.
Settings.py
DATABASES = {
'default': {},
'Alora': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Alora',
'USER': 'postgres',
'PASSWORD': 'somepassword',
}
}
Python Version
C:\Users\User>python --version
Python 3.6.3
Django Version
C:\Users\User>django-admin --version
2.2
Tried python manage.py createsuperuser --database=Alora.
Received the error stated above.
Any help is deeply appreciated.
Thanks!

Python django error

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

importError: No module named 'django.db.backends.util'

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.

Django MySql-Connector-Python - unknown error [duplicate]

OS : CentOS 6.4
python version 3.4
django version 1.8
I had studies about django framework. Then, I going to move to storage part. At first of study, the default database is sqlite. So I was change some values in the settings.py file.
#DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
#}
DATABASES = {
'default' : {
'ENGINE' : 'mysql.connector.django',
'NAME' : 'dj_mysql',
'USER' : 'root',
'PASSWORD' : '',
'HOST' : '127.0.0.1',
'PORT' :''
}
}
I typed "python3 manage.my migrate", and I got these errors.
How can I overcome this situation. TT;
I'm struggling all day long.
It looks like you're trying to use MySQL connector. The Django docs suggest that it doesn't always support the latest version of Django. This bug report suggests that 2.1.3 supports Django 1.8, but users were still reporting problems with 2.1.3 on that bug report and in this question.
The Django docs recommend that you use mysqlclient to access MySQL databases with Django.
It's easy to install, for example with pip:
pip install mysqlclient
Then all you need to do is change your databases setting to
DATABASES = {
'default' : {
'ENGINE' : 'django.db.backends.mysql',
...
You should update the mysql-connector-python, since the old version don't support Django 1.8 well.
As the documentation of Django goes:
MySQL Connector/Python is available from the download page. The Django >adapter is available in versions 1.1.X and later. It may not support the >most recent releases of Django.
Use the following command to update it from the MySQL website:
pip install http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz

Categories