WebAdminPanel/database/models.py

28 lines
632 B
Python
Raw Normal View History

2022-08-29 12:10:44 -04:00
from peewee import Model,CharField
from playhouse.db_url import connect
# TODO: create connection to bot database
db = connect("sqlite:///db.db")
class WebUser(Model):
username = CharField()
password_hash = CharField()
class Meta:
db_table = "webusers"
database = db
def userExists(self,username) -> bool:
"""Check if the username exists in a database."""
query = WebUser.select().where(WebUser.username == username)
if (not query) or (not query.exists()):
return False
return True
def build_models():
db.create_tables([WebUser])