python MySQL HOSxP
Python Extension Packages for Windows - Christoph Gohlke (uci.edu)
install mysql client python 3.9
pip install mysqlclient‑1.4.6‑cp39‑cp39‑win_amd64.whl
=================================================================
#myapp/settings/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'HOS',
'USER': 'sa',
'PASSWORD': 'sa',
'HOST': 'localhost', # Or an IP Address that your database is hosted on
'PORT': '3306',
#optional:
'OPTIONS': {
charset='utf8',
init_command='SET NAMES UTF8'
},
}
แบบนี้ใช้ได้
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'hosxp_pcu',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'charset' : 'utf8',
'use_unicode' : True,
'init_command': 'SET NAMES UTF8'
},
}
}
ความคิดเห็น
แสดงความคิดเห็น