WebAdminPanel/database.py

29 lines
628 B
Python

from peewee import Model,CharField
from playhouse.db_url import connect
from config import db_url
db = connect(db_url)
class WebUser(Model):
username = CharField()
password_hash = CharField()
class Meta:
db_table = "webusers"
database = db
@staticmethod
def userExists(username) -> bool:
"""Check if the username exists in a database."""
query = WebUser.select().where(WebUser.username == username)
if (query):
if (query.exists()):
return True
return False
def build_database():
db.create_tables([WebUser])