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 api ./api
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
# Install supervisord

View file

@ -12,7 +12,7 @@ def dict_factory(cursor, row):
return d
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.execute("UPDATE user SET password=? WHERE user_name=?", ( password,user_name,))
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!")
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!")
conn = sqlite3.connect('/usr/src/app/database.sqlite')
conn = sqlite3.connect('/usr/src/app/db/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,))

View file

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