소스 검색

Fix query

https
jakobsn 6 년 전
부모
커밋
5b102329d4
2개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. +6
    -4
      src/app/model.py
  2. +4
    -2
      src/app/views.py

+ 6
- 4
src/app/model.py 파일 보기

@@ -18,15 +18,17 @@ def get_users():


def match_user(username, password): def match_user(username, password):
cursor = db.cursor() cursor = db.cursor()
query = ("SELECT userid, username from users where username = (%s) and password = (%s)")
cursor.execute(query, (username, password))
query = ("SELECT userid, username from users where username = \"" + username +
"\" and password = " + password)
cursor.execute(query)
user = cursor.fetchall() user = cursor.fetchall()
return user return user


def set_user(username, password): def set_user(username, password):
cursor = db.cursor() cursor = db.cursor()
query = ("INSERT INTO users VALUES (NULL, (%s), (%s))")
cursor.execute(query, (username, password))
query = ("INSERT INTO users VALUES (NULL, " + username +
", " + password + ")")
cursor.execute(query)
cursor.close() cursor.close()


def get_guestbook_entries(): def get_guestbook_entries():


+ 4
- 2
src/app/views.py 파일 보기

@@ -44,10 +44,12 @@ class index():
data = web.input() data = web.input()
user = model.match_user(data.username, data.password) user = model.match_user(data.username, data.password)
# If there is a matching user/password in the database the user is logged in # If there is a matching user/password in the database the user is logged in
if len(user) == 1:
if len(user):
friends = model.get_users() friends = model.get_users()
session.username = data.username session.username = data.username
return render.index(login_form, friends)
else:
friends = [[],[]]
return render.index(login_form, friends)




class register: class register:


불러오는 중...
취소
저장