update plugin-password

This commit is contained in:
qiaofeng1227 2023-06-30 09:59:08 +08:00
parent 51f8513292
commit 130ec8b811
2 changed files with 17 additions and 10 deletions

View file

@ -10,7 +10,7 @@ COPY static ./static
COPY requirements.txt main.py database.sqlite ./
RUN apt update
# Install supervisords
# Install supervisord
RUN apt install -y supervisor
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/cmd.sh /cmd.sh

View file

@ -3,17 +3,24 @@ from pydantic import BaseModel
from api.model.user import User
import sqlite3
conn = sqlite3.connect('/usr/src/app/database.sqlite', check_same_thread=False)
cursor = conn.cursor()
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
def AppUpdateUser(user_name, password):
sql = "UPDATE user SET password=" + password + " WHERE user_name=" + user_name
cursor.execute(sql)
conn = sqlite3.connect('database.sqlite')
cursor = conn.cursor()
cursor.execute("UPDATE user SET password=? WHERE user_name=?", ( password,user_name,))
conn.commit()
conn.close()
def AppSearchUsers(user_type):
sql = "SELECT * FROM user WHERE user_type=" + user_type
cursor.execute(sql)
result = cursor.fetchall()
return result
conn = sqlite3.connect('/usr/src/app/database.sqlite')
conn.row_factory = dict_factory
cursor = conn.cursor()
cursor.execute("SELECT user_name,password,nick_name FROM user WHERE user_type=?", (user_type,))
rows = cursor.fetchone()
conn.close()
return rows