카테고리 없음
2022년 12월 첫주차 WIL
msdou45
2022. 12. 5. 08:48
2022년 12월 첫주차 WIL (제출은 12월 5일) 제출용 메모.
1. 이번 주 새롭게 배운 것들
1) 자료구조/알고리즘
2) git 강의
3) mysql, html, css
4) 타임어택 알고리즘
2. 이번 주 배운 것들 중에서 기억에 남는 부분
db = pymysql.connect(host="localhost", port=3306, user="root", db='sparta_test', password='', charset='utf8')
cur = db.cursor(pymysql.cursors.DictCursor)
sql = "select * from users where login_name = %s and pw = %s"
cur.execute(sql, (nick_name_receive, pw_receive))
select_result = cur.fetchall()
db.close()
위는 select 문
db = pymysql.connect(host="localhost", port=3306, user="root", db='sparta_test', password='1q2w3e4r',charset='utf8')
cur = db.cursor(pymysql.cursors.DictCursor)
sql = "INSERT INTO velog_post (title, content, login_name, user_id) VALUES (%s, %s, %s, %s)"
cur.execute(sql, (post_title_receive, post_content_receive, login_name_receive, user_id_receive))
db.commit()
post_id = cur.lastrowid # insert 된 레코드의 id 값
db.close()
다음으로는 insert문.
보다 시피, DB에 변화를 발생시키느냐 시키지 않느냐에 따라 commit 이냐 아니냐를 결정해야 해.
3. 다음 주 목표
2번째 미니 프로젝트 "화면 구현" 을 완성하자