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
|
|
|
|
|
2022-09-01 09:24:40 -04:00
|
|
|
@staticmethod
|
|
|
|
def userExists(username) -> bool:
|
2022-08-29 12:10:44 -04:00
|
|
|
"""Check if the username exists in a database."""
|
|
|
|
query = WebUser.select().where(WebUser.username == username)
|
|
|
|
|
2022-09-01 09:24:40 -04:00
|
|
|
if (query):
|
|
|
|
if (query.exists()):
|
|
|
|
return True
|
2022-08-29 12:10:44 -04:00
|
|
|
|
2022-09-01 09:24:40 -04:00
|
|
|
return False
|
2022-08-29 12:10:44 -04:00
|
|
|
|
|
|
|
def build_models():
|
|
|
|
db.create_tables([WebUser])
|