Skip to content

Commit 7b4e9a1

Browse files
committed
Full menus developed
1 parent 9e89b82 commit 7b4e9a1

29 files changed

+35782
-1007
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
secret.json
12

23
# Created by https://www.toptal.com/developers/gitignore/api/python,django,pycharm
34
# Edit at https://www.toptal.com/developers/gitignore?templates=python,django,pycharm

config/settings.py

+27-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"""
1212

1313
from pathlib import Path
14-
import os
14+
import os, json
15+
from django.core.exceptions import ImproperlyConfigured
1516

1617
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1718
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -21,7 +22,23 @@
2122
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
2223

2324
# SECURITY WARNING: keep the secret key used in production secret!
24-
SECRET_KEY = 'django-insecure-+@=(h#(sypl15um7ztljznaen@p)&_)d0(co7f%rj14male3ov'
25+
secret_file = os.path.join(BASE_DIR, 'secret.json') # secrets.json 파일 위치를 명시
26+
27+
with open(secret_file) as f:
28+
secrets = json.loads(f.read()) # python object로 바꿈
29+
30+
# 비밀번호를 가져오기 위한 함수
31+
def get_secret(setting, secrets=secrets):
32+
"""비밀 변수를 가져오거나 명시적 예외를 반환한다."""
33+
try:
34+
print("확인:", secrets[setting])
35+
return secrets[setting]
36+
except KeyError:
37+
error_msg = "Set the {} environment variable".format(setting)
38+
raise ImproperlyConfigured(error_msg)
39+
40+
SECRET_KEY = get_secret("SECRET_KEY")
41+
2542

2643
# SECURITY WARNING: don't run with debug turned on in production!
2744
DEBUG = True
@@ -130,3 +147,11 @@
130147
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
131148

132149
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
150+
151+
# # Email
152+
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
153+
EMAIL_HOST = 'smtp.googlemail.com'
154+
EMAIL_USE_TLS = True
155+
EMAIL_PORT = 587
156+
EMAIL_HOST_USER = get_secret("EMAIL_HOST_USER")
157+
EMAIL_HOST_PASSWORD = get_secret("EMAIL_HOST_PASSWORD")

data/data4_age_included.csv

+31,480
Large diffs are not rendered by default.

frame/custdb.py

-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ def insert6(self, id, pwd, name, age, height, weight):
3333
conn.commit()
3434
super().close(cursor, conn)
3535

36-
def insert7(self, id, pwd, name, age, height, weight, size):
37-
conn = super().getConn()
38-
cursor = conn.cursor()
39-
cursor.execute(Sql.custinsert7 %(id, pwd, name, age, height, weight, size))
40-
conn.commit()
41-
super().close(cursor, conn)
42-
4336
def update6(self, id, pwd, name, age, height, weight):
4437
conn = super().getConn()
4538
cursor = conn.cursor()

frame/schema.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ALTER TABLE customer MODIFY COLUMN age INT NOT NULL;
1818
ALTER TABLE customer MODIFY COLUMN height FLOAT NOT NULL;
1919
ALTER TABLE customer MODIFY COLUMN weight INT NOT NULL;
2020

21-
INSERT INTO customer VALUES('id01', 'pwd01', '김영희', 31, 183.1, 63, ''); # ''은 값이 있는 것으로 인식됨
21+
INSERT INTO customer VALUES('id01', 'pwd01', '김영희', 31, 183.1, 63, ''); # '', 'NULL' 은 값이 있는 것으로 인식됨
2222
INSERT INTO customer VALUES('id02', 'pwd01', '이영주', 24, 167.9, 71, NULL);
2323

2424

frame/sql.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
class Sql:
22
custselone = "SELECT * FROM customer WHERE id='%s'"
33
custselall = "SELECT * FROM customer"
4-
custinsert6 = "INSERT INTO customer(id, pwd, name, age, height, weight) VALUES ('%s', '%s', '%s', %d, %f, %d)"
5-
custinsert7 = "INSERT INTO customer VALUES ('%s', '%s', '%s', %d, %f, %d, '%s')"
4+
custinsert = "INSERT INTO customer(id, pwd, name, age, height, weight) VALUES ('%s', '%s', '%s', %d, %f, %d)"
65
custupdate6 = "UPDATE customer SET pwd='%s', name='%s', age=%d, height=%f, weight=%d WHERE id='%s'"
76
custupdate7 = "UPDATE customer SET pwd='%s', name='%s', age=%d, height=%f, weight=%d, right_size='%s' WHERE id='%s'"
87
custdelete = "DELETE FROM customer WHERE id='%s'"

0 commit comments

Comments
 (0)