xxxxxxxxxx
#install mysqlclient in your django project
(env) $ pip install mysqlclient
#create the database using phpMyAdmin, MySQL Workbench,
#or MySQL Command Line Client
#update the DATABASES dictionary in settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'database_name',
'USER': 'database_username(default: root)',
'PASSWORD': 'database_password(default:'')',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
}
}
#migrate!
(env) $ python manage.py migrate
xxxxxxxxxx
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'USER': 'DB_USER',
'PASSWORD': 'DB_PASSWORD',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
xxxxxxxxxx
You need to make changes in project settings.py.
Provide USER and PASSWORD for your database
If your database isn't mysql change ENGINE
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'USER': 'root',
'PASSWORD': 'rootpassword',
'HOST': 'localhost',
'PORT': '',
}
}
xxxxxxxxxx
# generate eastcoders swahili
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'USER':'root',
'NAME':'myTeacher',
'HOST':'127.0.0.1',
'PASSWORD': '',
'PORT':'3308',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
}
}
}
xxxxxxxxxx
pip install psycopg2 or pip install mysqlclient
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASSWORD"),
'HOST': os.getenv("DB_HOST"),
}
}
xxxxxxxxxx
No pyenv needed, this works perfect for me:
brew install python@3.7
brew install python@3.8
brew install python@3.9
Then just add the corresponding version lines to the ~/.bashrc
export PATH="$PATH:/usr/local/opt/python@3.7/Frameworks/Python.framework/Versions/3.7/bin"
export PATH="$PATH:/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/bin"
export PATH="$PATH:/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin"