db chanage

This commit is contained in:
qiaofeng1227 2023-08-17 16:05:24 +08:00
parent b0e4b12e84
commit 4078bd63bd
3 changed files with 9 additions and 5 deletions

View file

@ -8,7 +8,9 @@ WORKDIR /usr/src/app
# Copy source and install pip dpendencies # Copy source and install pip dpendencies
COPY api ./api COPY api ./api
COPY static ./static COPY static ./static
COPY requirements.txt main.py hostname.py database.sqlite ./ COPY requirements.txt main.py hostname.py ./
RUN mkdir /usr/src/app/db
COPY database.sqlite /usr/src/app/db/
RUN apt update RUN apt update
# Install supervisord # Install supervisord

View file

@ -12,7 +12,7 @@ def dict_factory(cursor, row):
return d return d
def AppUpdateUser(user_name, password): def AppUpdateUser(user_name, password):
conn = sqlite3.connect('/usr/src/app/database.sqlite') conn = sqlite3.connect('/usr/src/app/db/database.sqlite')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("UPDATE user SET password=? WHERE user_name=?", ( password,user_name,)) cursor.execute("UPDATE user SET password=? WHERE user_name=?", ( password,user_name,))
conn.commit() conn.commit()
@ -23,7 +23,7 @@ def AppSearchUsers(user_type):
raise CommandException(const.ERROR_CLIENT_PARAM_BLANK, "This plugin is blank!", "This plugin is blank!") raise CommandException(const.ERROR_CLIENT_PARAM_BLANK, "This plugin is blank!", "This plugin is blank!")
if user_type != "nginx" and user_type != "portainer": if user_type != "nginx" and user_type != "portainer":
raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "This plugin doesn't exist!", "This plugin doesn't exist!") raise CommandException(const.ERROR_CLIENT_PARAM_NOTEXIST, "This plugin doesn't exist!", "This plugin doesn't exist!")
conn = sqlite3.connect('/usr/src/app/database.sqlite') conn = sqlite3.connect('/usr/src/app/db/database.sqlite')
conn.row_factory = dict_factory conn.row_factory = dict_factory
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("SELECT user_name,password,nick_name FROM user WHERE user_type=?", (user_type,)) cursor.execute("SELECT user_name,password,nick_name FROM user WHERE user_type=?", (user_type,))

View file

@ -8,7 +8,8 @@ services:
privileged: true privileged: true
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- appmanage:/usr/src/app - appmanage-logs:/usr/src/app/logs
- appmanage-db:/usr/src/app/db
entrypoint: bash -c "/cmd.sh" entrypoint: bash -c "/cmd.sh"
ports: ports:
- ${APP_HTTP_PORT}:5000 - ${APP_HTTP_PORT}:5000
@ -19,4 +20,5 @@ networks:
external: true external: true
volumes: volumes:
appmanage: appmanage-logs:
appmanage-db: