1

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

i do not have an idea about how to use SQL database also in my Django project please provide me a simple as well as easy way to do. i want to use multiple database as well the default one and mySQL database

cool kumar
  • 11
  • 1
  • 2
    [multiple databases and multiple models in django](http://stackoverflow.com/questions/18547468/multiple-databases-and-multiple-models-in-django) – Solarflare Sep 09 '16 at 07:42
  • OK I am unclear about what you want exactly so unlike others, rather than vote you down, I will ask you to clarify. Are you asking how to connect to and use a MySQL database ? – kerry Sep 09 '16 at 07:48
  • yah actually i did install django 1.9 and try to install mysql libraries and component but i am unable to find.. so i dont have an idea what i need to do for use the mysql as my database can anyone help explain and give me source thanku – cool kumar Sep 09 '16 at 09:09
  • OK so if I understand you, you want to use MySQL and not use Django. In that case you should look at MySQL database and PHP as a programming or scripting tool. These 2 work very well together for integrating databases into web sites. There are many tutorials on the web - just google PHP Mysql tutorial. To teach you how to use the 2 for web design and integration is really beyond the scope of this forum. Basically you use PHP for programming and sending SQL queries to MySQL. I can happily give you some examples. You should look also at downloading easyPHP as a development tool. – kerry Sep 09 '16 at 09:34
  • No no no. I think that's not what he's asking. He wants to use django with MySQL db which is a easy possibility. Kumar, can you kindly just clarify whether you do indeed need two databases(i.e.also need SQLite one)?? or if you just want to have MySQL db and not SQLite db. That is also possible in Django. let me know and I'll share the code accordingly. – Sarosh Khatana Sep 09 '16 at 11:49

2 Answers2

0

Write this code in settings.py file--

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
            'read_default_file': '/path/to/my.cnf',
        },
    }
}
Amandeep Dhiman
  • 582
  • 3
  • 8
  • 21
0

Looks like you facing problems setting up Django with MySQL. Try this -

$ pip install mysql-python

If you still face issues I'd suggest read through a tutorial, something like this. Hope that helps.

user6399774
  • 116
  • 6