some improvements
This commit is contained in:
13
modules/README.md
Normal file
13
modules/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# THE MODULES
|
||||
|
||||
## the modules in this folder are used to make a more viewable server code possible.
|
||||
## code that is either needed in different filed over the server folder structure is placed in an module and imported by some other files or just code sections which are doing replicated things like reading or writing data to something.
|
||||
|
||||
## db.py
|
||||
### in the DB module are some SQLite commands in functions. Each of them returns datasets according to it names so e.g. in Blueprint routing u only have to call a function to get your dataset which leads to more structured code.
|
||||
|
||||
## persistence
|
||||
### the persistence module contains just some functions to manage the in the persistence given JSON objects
|
||||
|
||||
## socketio
|
||||
### socketio is the main socket/flask server instance and some functions to manage communication
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
DB_PATH = os.path.join(os.path.dirname(__file__), '../db/commands.db')
|
||||
DB_PATH_COFFEE = os.path.join(os.path.dirname(__file__), '../db/coffee.db')
|
||||
|
||||
### THIS CODE IS NOT PROOFED BUT LOOKS RIGHT###
|
||||
def update_command_status(command_id, status):
|
||||
@@ -19,4 +20,24 @@ def update_command_status(command_id, status):
|
||||
conn.close()
|
||||
print(f"[DB] Befehl {command_id} auf {status} aktualisiert.")
|
||||
return status
|
||||
### THIS CODE IS NOT PROOFED BUT LOOKS RIGHT###
|
||||
### THIS CODE IS NOT PROOFED BUT LOOKS RIGHT###
|
||||
|
||||
def get_coffee_count():
|
||||
conn = sqlite3.connect(DB_PATH_COFFEE)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM coffee")
|
||||
count = cursor.fetchone()[0]
|
||||
|
||||
conn.close()
|
||||
return count
|
||||
|
||||
def get_coffees():
|
||||
conn = sqlite3.connect(DB_PATH_COFFEE)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT * FROM coffee")
|
||||
coffees = cursor.fetchall()
|
||||
|
||||
conn.close()
|
||||
return coffees
|
||||
Reference in New Issue
Block a user