+1 vote
in Python by
Explain how can we build or set up the database in Django?

1 Answer

0 votes
by
we can make use of edit mysite/setting.py command, it is a simple Python module consists of levels for presenting or displaying Django settings.

By default Django uses SQLite; this also makes easy for Django users in case of any other type of installations. For example, if your database choice is different then you need to follow certain keys in the DATABASE like default items to match database connection settings.

Engines: By these engines you change the database by using commands such as ‘django.db.backends.postgresql_psycopg2’, ‘django.db.backends.sqlite3’, ‘django.db.backends.oracle’, ‘django.db.backends.mysql’, and so on.

Name: This represents the name of your own database. If you are familiar with using SQLite as your database, in such case database is available as a file on your particular system. Moreover, the name should be as a fully absolute or exact path along with the file name of the particular file.

Suppose if we are not using SQlite as your database then additional settings such password, user, the host must be added.

Django mainly uses SQLite as its default database to store entire information in a single file of the filesystem. If you want to use different database servers rather than SQLite, then make use of database administration tools to create a new database for the Django project.  Another way is by using your own database in that place, and remaining is to explain Django about how to use it. This is the place in which Python’s project settings.py file comes into the picture.

We need to add the below code to the setting.py file:

DATABASE  = {

‘Default’ : {

‘ENGINE’ :  ‘django.db.backends.sqlite3’,

‘NAME’ : os.path.join(BASE_DIR, ‘db.sqlite3’),

}

}

Related questions

+1 vote
asked May 23, 2020 in Python by sharadyadav1986
0 votes
asked May 17, 2020 in Python by sharadyadav1986
...